W3C home > Mailing lists > Public > public-html@w3.org > October 2009

Property enumeration on forms

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Fri, 23 Oct 2009 17:41:56 -0400
Message-ID: <4AE22324.1070206@mit.edu>
To: HTML WG <public-html@w3.org>
Consider this testcase:

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

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?

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

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:45:01 UTC