[whatwg] HTMLCollection and HTMLAllCollection suggestion
david at davidflanagan.com
Mon Apr 5 11:04:13 PDT 2010
Perry Smith wrote:
> On Apr 3, 2010, at 11:58 PM, David Flanagan wrote:
>> Perry Smith wrote:
>>> HTMLCollection has a namedItem method that returns either null or one
>>> object. 
>>> HTMLAllCollection has a namedItem method that returns either null,
>>> one object, or a collection of objects. 
>>> I'm a Rails freak and one of the things that they do which I love is
>>> foo returns an item and foos returns a list of items. The
>>> unconscious benefit of this I believe is huge.
>>> My suggestion is to have namedItem always return either null or 1
>>> And have namedItem*s* always return a collection. We can debate
>>> whether it is better to return null or an empty collection. I prefer
>>> the latter myself. Then I can always feed it to an iterator.
>> But no one actually invokes namedItem()--they just use a regular
>> property access expression on an HTMLAllCollection. namedItem() is
>> left over from the strange days when the W3C was specifying Java APIs
> Hmm. I was wondering. The pop up boxes on the side did not have any
> icons in them so I thought no one had implemented them.
> Can you give me an example of "regular property access expression on an
> HTMLAllCollection" ? I can't figure out what you are referring to.
I think the only HTMLAllCollection is the deprecated document.all.
By regular property access expression, I mean something like:
More information about the whatwg