"Richard Cornford" <Richard@litotes.demon.co.uk> writes:
[color=blue]
> <quote>
> Interface HTMLFormElement
> The FORM element encompasses behavior similar to a collection
> and an element. It provides direct access to the contained form
> controls as well as the attributes of the form element.
> ...
> length of type long, readonly
> The number of form controls in the form.
> </quote>[/color]
I can see why this can be taken to mean that the HTML element is a
collection itself. However, the IDL in DOM 2 HTML can be used in
strictly typed OO languages, like Java or C++, to create objects
implementing the HTMLFormElement interface. They have no provision
for adding arbitrarily named propertie to such objects.
With that in mind, I read the "compasses behavior similar to a
collection" as merely saying what should be possible through the
FormElement, not how it is implemented. The implementation makes
the collection behavior available through the "elements" collection.
Compare it to the HTMLSelectElement. It says:
---
The contained options can be directly accessed through the select
element as a collection.
---
Again, I could read it as saying that a select element should act
as a collection, but all the interface requires is that it *contains*
the options collection. Select elements also have a length property
which duplicates the one in the options collection.
So, reading the DOM 2 IDL as a specification for Java, there is no way
forms or selects can be collections - they don't have the appropriate
methods (item, namedItem). There is nothing in the ECMAScript binding
that makes it special (as there is for collections, allowing access
through the [...] property accessor).
[color=blue]
> That is my interpretation of "behavior similar to a collection" and
> "direct access to the contained form controls". On the grounds that if
> it is a collection it has to be a collection of something and the form
> elements ore the obvious candidate, and I would describe making the
> elements available through the - elements - collection as indirect.[/color]
The elements property is read-only and is bound to this particular
form. Thinking in OO modelling terminology, that makes it a component
of the form element, not just reference by it. Having a collection
component would count as direct enough for me.
[color=blue]
> A lot of the HTML DOM is a formalisation of existing browser behaviour,
> but it probably was a mistake for the W3C to do this (assuming you
> cannot find a reasonable alternative interpretation0.[/color]
I try :) But only because your interpretation makes no sense in, e.g.,
Java with the defined interface, and there is no sign that the
ECMAScript binding is doing anything special.
/L
--
Lasse Reichstein Nielsen -
lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'