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

On Thu, 6 Sep 2012, Simon Pieters wrote:
> On Wed, 05 Sep 2012 22:47:07 +0200, Ian Hickson <ian@hixie.ch> wrote:
> > 
> >   http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1736
> > 
> > Webkit returns undefined, whereas IE, Gecko, and Opera all return an 
> > HTMLCollection. (IE returns an HTMLCollection with a tags() method, 
> > Gecko and Opera do not. The spec requires an HTMLAllCollection, which 
> > is the kind of collection that has a tags() method in the spec; in IE, 
> > all collections have a tags() method, and document.all is actually a 
> > regular HTMLCollection. We could change the spec here, e.g. to put 
> > tags() on all collections or to just forget about tags() on the 
> > subcollection here.)
> 
> I thought we had agreed to drop tags() everywhere except for the 
> document.all collection. I guess the collection returned by 
> document.all.foo wasn't discussed back then, though. Opera and Firefox 
> don't support tags() there, which suggests it's not needed for compat, 
> so maybe the spec should side with Opera/Firefox and return 
> HTMLCollection instead of HTMLAllCollection.

Ok, I've made document.all.foo return an HTMLCollection.


On Thu, 6 Sep 2012, Ojan Vafai wrote:
> On Wed, Sep 5, 2012 at 1:47 PM, Ian Hickson <ian@hixie.ch> wrote:
> >
> > For HTMLOptionsElement, the situation is more murky.
> >
> >    http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1739
> >
> > From what I can tell, IE doesn't do direct named access, you have to 
> > do it via item() or namedItem(). The spec didn't support item() access 
> > for names, though all the browsers did. I've filed a bug on DOM Core 
> > for that. Using namedItem(), you see that IE returns a live 
> > HTMLCollection, the spec returns a live NodeList, WebKit returns a 
> > static NodeList, and Opera and Firefox return just the first option. 
> > (There's a note in the spec asking if we should switch to 
> > HTMLCollection rather than NodeList.)
> 
> I haven't followed the details closely enough to know which APIs should 
> be returning which types of lists/collections. As a general point 
> though, anywhere we can avoid live NodeLists/Collections is a big 
> improvement. They impose a significant implementation cost both in terms 
> of complexity and in terms of performance impact.

Ok, I've changed to match Opera and Firefox on this one, since that was 
the least complex solution.

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

Received on Friday, 14 December 2012 23:53:09 UTC