Re: Attributes and "Expandos"

On Fri, 22 Jun 2007, Maciej Stachowiak wrote:
> > 
> > IE, has the concept of “expandos”, meaning it also creates reflecting 
> > DOM attributes on the corresponding element for unknown content 
> > attributes (case-sensitive). Obviously HTML5 does not define DOM 
> > attributes for unknown content attributes, however is there any 
> > general guidelines for reflecting (or not) unknown content attributes 
> > in the DOM, or is that left to the UA’s discretion?

I don't think anything explicitly forbids it, but I would caution strongly 
against it. It causes all kinds of forwards-compatibility issues which 
make it harder to extend the language going forward.

> I think the following two aspects are non-conforming, although mainly to 
> DOM Core rather than to HTML5:
> 1) getAttribute sometimes returns a non-string, for standard attributes 
> that have corresponding non-string DOM attributes. For example 
> getAttribute("onclick").

This is certainly non-conforming, as is the way that some attributes don't 
actually contain what was in the markup. That is, the DOM and content 
attributes sometimes should have different values, and in IE they seem to 
always have the same value.

> 2) Setting a custom property on an element results in an attribute on 
> the element that is visible to getAttribute and serialized via 
> innerHTML.

This is arguably just part of the non-standard "expando" extension.

> I don't think adding a custom property for a nonstandard attribute is 
> nonconforming to anything, but is likely to cause compatibility problems 
> with scripts as the language evolves and is probably more confusing than 
> helpful if you fix issues 1 and 2.
> Other browsers generally don't have this IE-specific quirk.

Yeah. I would strongly recommend against continuing this quirk.

I can put stuff in the spec about it if it is desired, but I think it's 
more likely to be something that would be covered in heycam's JS/DOM 
integration spec.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 22 June 2007 21:20:52 UTC