[Webkit-unassigned] [Bug 22749] New: Common array iteration schemes fail on NamedNodeMaps.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Dec 8 20:26:14 PST 2008


https://bugs.webkit.org/show_bug.cgi?id=22749

           Summary: Common array iteration schemes fail on NamedNodeMaps.
           Product: WebKit
           Version: 525.x (Safari 3.1)
          Platform: Macintosh Intel
        OS/Version: Mac OS X 10.5
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: HTML DOM
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: mikesamuel at gmail.com
                CC: ojan at google.com


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>


-- 
Configure bugmail: https://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