WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
22749
Common array iteration schemes fail on NamedNodeMaps.
https://bugs.webkit.org/show_bug.cgi?id=22749
Summary
Common array iteration schemes fail on NamedNodeMaps.
mikesamuel@gmail.com
Reported
2008-12-08 20:26:14 PST
Symptom ======= The HTML below tries a number of common array iteration schemes over a form's elements list. Safari is the only common browser that fails on the second, common one. The third works on all browsers but is never used. Note, Safari breaks in other ways if <input name=elements id=elements> is present. Expected ======== In a NamedNodeMap or HtmlCollection, Elements with ids or name properties should not mask properties specified in the DOM2 Core or HTML APIs. Test ==== <html> <head> <title>NamedNodeList Iteration</title> </head> <body> <form> <input name=length id=length> <input name=3 id=3> <input name=0 id=0> </form> <p>The correct output is</p> <ol> <li>i=0 : length <li>i=1 : 3 <li>i=2 : 0 </ol> <script>(function () { function testIteration(nodeList, description) { document.write('<h1>' + description + ' Method 1</h1><ul>'); // Fails on IE6 & Opera9 // Works on FF2, Safari3 for (var i = 0, len = nodeList.length; i < len; ++i) { var node = nodeList[i]; document.write('<li>i=' + i + ' : ' + node.name); } document.write('</ul>'); document.write('<h1>' + description + ' Method 2</h1><ul>'); // Works on IE6, Opera9, FF2 // Fails on Safari for (var i = 0, node; (node = nodeList[i]); ++i) { document.write('<li>i=' + i + ' : ' + node.name); } document.write('</ul>'); document.write('<h1>' + description + ' Method 3</h1><ul>'); // Works on IE6, Opera9, FF2, Safari var limit = nodeList.length; if (limit !== +limit) { limit = 1/0; } for (var i = 0, node; i < limit && (node = nodeList[i]); ++i) { document.write('<li>i=' + i + ' : ' + node.name); } document.write('</ul>'); } testIteration(document.forms[0].elements, 'Form Elements'); testIteration(document.getElementsByTagName('input'), 'ByTagName'); })(); </script> </body> </html>
Attachments
test case
(1.54 KB, text/html)
2008-12-09 03:29 PST
,
Alexey Proskuryakov
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2008-12-09 03:29:03 PST
Created
attachment 25880
[details]
test case Same test as an attachment.
Ahmad Saleem
Comment 2
2022-05-29 08:16:35 PDT
Unable to reproduce on Safari 15.4 on macOS and the output from attachment test case is consistent across Chrome Canary 104 and Firefox Nightly 102. This bug can be closed. Thanks!
Alexey Proskuryakov
Comment 3
2022-05-31 10:32:35 PDT
Thank you for checking!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug