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

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 UTC