[whatwg] HTML 5 : Misconceptions Documented

On Tue, Aug 5, 2008 at 8:03 AM, Garrett Smith wrote:
> On Mon, Aug 4, 2008 at 3:17 PM, Thomas Broyer wrote:
>>
>> Actually, there is:
>> http://www.w3.org/TR/html5/dom.html#htmlcollection
>> and I believe the "elements" property of HTMLFormElement is actually
>> an HTMLFormControlsCollection:
>> http://www.w3.org/TR/html5/dom.html#htmlformcontrolscollection
>>
>
> First off, the IndexGetter behavior on the HTMLCollection[1] is the
> authors imagination.

Aren't "document.forms[0]" and "document.forms.myform" working?

> The following example shows that indexed Properties exist on
> NamedNodeMap, HTMLCollection, NodeList (just like they do on Arrays).
> There is no [[ IndexGetter ]] as Cameron likes to make pretend.

This is an "implementation detail" of the ECMAScript binding.

In C#, these would obviously be mapped to indexers ("public
HTMLElement this[int index] { get { ... } }" and "public object
this[String name] { get { ... } }"), and there is no equivalent in
Java.
I guess that in Python and Ruby, which share their "dynamic" nature
with ECMAScript, these wouldn't be true properties as well (i.e. '0'
in document.forms would be False, and document.forms["0"] wouldn't be
equivalent to document.forms[0])


-- 
Thomas Broyer

Received on Tuesday, 5 August 2008 16:02:18 UTC