[whatwg] Why do HTML*Collection's nameItem need to return 5 different objects?

Ian Hickson ian at hixie.ch
Fri Jul 13 15:17:28 PDT 2012


On Fri, 13 Jul 2012, Ryosuke Niwa wrote:
>
> According to
> http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlpropertiescollection
> 
> *HTMLCollection* returns the first element.

This is for compat in the default case, I believe.


> *HTMLAllCollection* returns the first element or another HTMLAllCollection
> if there are multiple elements

This is needed for IE compat.


> *HTMLFormControlsCollection* returns the first element or RadioNodeList if
> there are multiple elements

This is needed to support the radio button value feature.


> *HTMLOptionsCollection* returns the first element or live NodeList if there
> are multiple elements

This is for compat, I believe. (We don't want to return just a node if 
there are many matching.)


> *HTMLPropertiesCollection* returns PropertyNodeList

This is to support the value features for microdata.


> Can those 3 classes somehow return the same object? FWIW, WebKit has 
> always returned a static node list.

WebKit doesn't support the microdata and radio button features, 
presumably, and is presumably less than perfectly compatible with the Web 
for the others. :-)

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



More information about the whatwg mailing list