[whatwg] boolean attributes in javascript

On Tue, Dec 8, 2009 at 4:49 PM, Dean Edwards <dean.edwards at gmail.com> wrote:
> On 08/12/2009 23:04, Garrett Smith wrote:
>>
>> Setting an attribute to the empty string may have the effect of
>> removing the attribute in some browsers.
>
> Which browsers/properties?
>

s/removing the attribute/setting a false value.

Try setting a 'checked' property of an input checkbox in IE.

<input type="checkbox" checked id="checkboxInput">

checkboxInput.setAttribute("checked", "");

will un-check a checkbox in IE.

The phenomenon is explained by two factors:
1) In IE < 8, attributes are properties (IE8 has some fixes)
2) Setting a boolean property to a non-boolean value may result in
boolean conversion.

Received on Tuesday, 8 December 2009 17:40:04 UTC