MooTools handles that deprecated setting of null. If the property is null
when passed, it calls removeAttribute.
All properties passed to the Element constructor use setAttribute, unless it
has an entry in Elements.Properties. If you wanted it to work with booleans,
you could add it like so:
Element.Properties.checked = {
set: function(val) {
this.checked = val;
},
get: function() {
return this.checked;
}
};
On Tue, Nov 30, 2010 at 11:54 AM, Sanford Whiteman <
[email protected]> wrote:
> > Like I said, the spec says checked="anything" means the checkbox is
> checked.
>
> Expectation when using new Element() is that underlying it is a
> wrapped/emulated DOM method. Whether you are internally calling DOM
> dot-property or DOM setAttribute, however, is not clear.
>
> · Using dot-property, the "one-value value list" attrs such as
> `checked` or `disabled` are definitely to be exposed as booleans per
> the DOM spec, although using dot-property at all is deprecated.
>
> · Using setAttribute('checked',...) is to be more of a dumb injection
> of the string value as it would appear in the markup, so
> setAttribute('checked','checked') would be the underlying logic *if
> you are specifying the value*. However, setAttribute('checked',null)
> is deprecated! You are supposed to use removeAttribute (or just not
> set the attribute).
>
> So when you're given upper level abstraction offered by the framework
> (just passing a default attributes object in to the constructor), you
> have a choice between two deprecated interpretations. My personal
> feeling is that dot-property is the clearest mechanism to emulate,
> since at least both "directions" are obvious, but I could see an
> argument for the other way.
>
> -- Sandy
>
>