Skip to content
Astera Technology

Remove a boolean attribute to turn it off

Test boolean attribute presence instead of treating its written string as a true or false value.

The string false does not switch off a present disabled attribute.

Download complete case notes and answer keys ↓

Inspect the working example

The first input deliberately contains the invalid boolean spelling disabled="false". Browsers still treat disabled as present. The second input has no disabled attribute and is editable. This is a repair lesson, not a recommended way to serialize a boolean.

Inputs and native observations
CaseInput or inspectionResult and meaning
Present with false textInspect frozen.hasAttribute("disabled")True; frozen.disabled=true; effective state disabled
AbsentInspect editable.hasAttribute("disabled")False; editable.disabled=false; it is editable
RepairRemove disabled from frozenIts disabled property becomes false
Download editable CSV ↓

Follow the browser mechanism

For an HTML boolean attribute, presence represents true and absence represents false. Valid authoring uses an empty value or the attribute’s name, rather than the strings true or false. Do not insert disabled="false" when a template flag is false; omit disabled entirely. This fixture has no disabled ancestor, so absence also makes this input effectively enabled.

An empty boolean value is still true

Changing false to an empty string does not remove the attribute. This correctly spelled boolean attribute still expresses the disabled state.

Counterexample source; inspect separately
<label>Sample <input id="frozen" type="text" disabled="" value="A"></label>

hasAttribute("disabled") remains true and disabled remains true. The successful repair removes the attribute, not its text alone.

Try the repair

Your template flag is false. Should its HTML output be disabled="false", disabled="", or no disabled attribute?

Show the worked answer

Omit the disabled attribute. Both written forms leave the attribute present and the field disabled in this fixture.

  • Test hasAttribute and effective interaction after the repair.
  • Check ancestor fieldsets separately when interpreting enabled state.

Original example files

Related resources