[Webkit-unassigned] [Bug 14901] for in loop on an Array does not work

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 8 08:04:41 PDT 2007


http://bugs.webkit.org/show_bug.cgi?id=14901





------- Comment #6 from atrasatti at mtld.mobi  2007-08-08 08:04 PDT -------
(In reply to comment #5)
> (In reply to comment #4)
> > var children = document.getElementsByTagName('SELECT');
> > alert(children.length);
> > for (var c in children) {
> >    alert('loop '+c);
> > }
> 
> The result of getElementsByName is not an array, it is a NodeList. for-in
> enumerates properties of the NodeList object. To enumerate the nodes in the
> NodeList you can do something like
> for (var i = 0; i < children.length; i++)
>     alert('loop' + children[i]);
> 

True, nevertheless for-in works fine on MSIE7 and FF2. Isn't the NodeList
enumerated? Why would for work and for-in not?
It seems to me like the suggested loop, which is actually the exact same thing
I did to fix it with Safari, should behave the same way as a for-in, while the
for-in has a more compact syntax and is more readable, in this case.


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list