W3C home > Mailing lists > Public > public-html@w3.org > July 2008

Re: HTMLCollection item() vs. namedItem() with [] syntax (detailed review of the DOM)

From: Cameron McCormack <cam@mcc.id.au>
Date: Sat, 26 Jul 2008 13:15:54 +1000
To: public-html <public-html@w3.org>
Message-ID: <20080726031554.GD29837@arc.mcc.id.au>

Hi Garrett.

Garrett Smith:
> Is this in reference to " [IndexGetter]" on "OrderedMap"
> http://www.w3.org/TR/DOM-Bindings/#IndexGetter

Yes, [IndexGetter] is meant to allow that kind of object indexing.
(That OrderedMap is just an example of how to use it.)

> The major browsers allow access of items in a collection via
> property-access operators.
> 
> The browser adds named properties to the Collection object in all of
> the major browsers.
> 
> ====================================
> <form><input></form>
> 
> javascript:alert(({}).hasOwnProperty.call(document.forms[0].elements, 0));
> ====================================
> 
> FF3, IE7, Saf3: true
> Op9: false[1]
>
> ====================================
> javascript:alert("0"in document.forms[0].elements)
> FF3, IE7, Saf3, Op9: true
> ====================================
> 
> [1] Opera 9 bug: does not return true for hasOwnProperty on a Host object.
> 
> Any assumption that there is a modified [[Get]] for the collection
> would be wrong.

I see.  If we want to specify that (that they are real properties that
exist on the object), then I think it will be hard for Web IDL to
provide some syntactic description of this behaviour.  So it would then
be up to HTML to state that properties get created and removed when
elements are added and removed from the document.

-- 
Cameron McCormack ≝ http://mcc.id.au/
Received on Saturday, 26 July 2008 03:16:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:19 GMT