Property enumeration on forms

Consider this testcase:

   <form id="x">
     <input name="myInput">
     <input>
   </form>

If I now do:

       var form = document.getElementById("x");
       for (var i in form) {
         document.writeln(i + " -- " + form[i]);
       }

I see the following behavior in different engines:

Webkit: has properties named 0 and 1 for the two elements
Opera: has properties named 0 and 1 for the two elements
IE8: has properties named myInput and 1 for the two elements
Gecko: has a property named myInput for the first element
        (the lack of a property named 1 is just a bug;
        it's _trying_ to have one, but failing).

None of the browsers seem to have all of 0, 1, myInput in the 
enumeration.  All do what one would expect if actually doing form[1], 
form[1], form.myInput.

Obvious questions:

1)  What should the right behavior be here.
2)  How is one to infer this behavior from the idl?
3)  Should question 2 be asked on public-script-coord instead?

-Boris

Received on Friday, 23 October 2009 21:42:38 UTC