Richard said:
Being a collection would be a recognisable absolute state, while being
similar to a collection is at best ambiguous. Having a - length -
property that dynamically reflects the number of form controls
contained in a form is being similar, not having any form control
retrieval methods represents not being the same as a collection.
The spec says:-
It provides direct access to the contained input elements as well as the
attributes of the FORM element.
Being similar to a collection is not descriptive enough (vague). The
length property is not significant to being similar to a collection.
A collection is, in the general sense of the word, an object that holds
other objects, either indexed or keyed. Describing a form element as
being similar to a collection, first and foremost, solely on the basis
that it has a length property would be misplaced.
It would be shorter to say that the form has length property, however,
the length property is not that significant to warrant placement as the
first sentence in the under the heading HTMLFormElement. In fact, the
length property defined below that.
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-40002357
I think the authors intentionally left out defining "direct access". I
think they were aware of browsers allowing named controls being
accessible directly off the form but couldn't specify that in IDL.
Specifications are not in the business of vaguely describing things.
Similar to a collection sounds vague to me. You said ambiguous, but I
think vague is more appropriate.
But we can see that when using a string as a
property, the indexed element is returned.
The initial nature of the value of the expression used in a bracket
notation property accessor is irrelevant as they are always type-
converted into strings in property accessor algorithm. The ECMAScript
bindings for the DOM don't get any say in that, they can only suggest
that (like the Array [[Put]] method) some action is taken based on the
value (characters in) of that string.
[snip]
The square bracket property accessors do not do type checking.
Not on native objects and not when used on DOM elements. The
Expression is converted to a string.
And that is stated in the article:-
| Contrary to what the [DOM 1] specification states, the [ ] property
| access operator does not perform a typecheck. In ECMAScript, property
| access is performed with obj[ Expression ] or obj . Identifier.
....
| When the property access operator is used, the Expression is converted
| to a string with the internal ToString.
I've also mentioned on the html mailing lists:
http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-August/015684.html
http://lists.w3.org/Archives/Public/public-html/2008Jul/0169.html
And the example shows that
document.forms[0]["0"] is the same as document.forms[0][0];
As the ECMAScript specification requires it to be.
That is how property access works. But that is not what DOM 0 says.
We can talk about Java in this context because the HTML DOM Java
bindings are also pertinent when considering intentions regarding the
HTMLFormElement interface. Java has no equivalent of bracket notation
property accessors so when it accesses a collection it has to use
methods. The Java bindings for HTMLCollection have those methods (as
do NodeList, etc.), but the bindings for HTMLFormElement do not. It is
hardly reasonable to assert that a specification framed in IDL and
provided with bindings for ECMAScript and Java should only be
referring only to ECMAScript implementations when saying "encompasses
behaviour similar to a collection", and as an interpretation of that
text that suggests the HTMLFormElement be a collection is contradicted
by the omissions in the Java bindings (in addition to the ECMAScript
bindings) it becomes necessary to read the text as having another
intended meaning.
I've updated pages 1, 2, and the conclusion. Accessing controls directly
off the FORM is non-standard. A FORM is not an HTMLCollection, but it
acts like a collection in a non-standard way. Web forms 2.0 is trying to
standardize the behavior.
Looking forward to more comments.
Garrett