2009-11-29 Shu Chang <Chang.Shu@nokia.com>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Nov 2009 01:02:43 +0000 (01:02 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Nov 2009 01:02:43 +0000 (01:02 +0000)
        Reviewed by Eric Seidel.

        Test using Id as index of node list.
        https://bugs.webkit.org/show_bug.cgi?id=31428

        * fast/dom/Element/id-in-node-list-index01-expected.txt: Added.
        * fast/dom/Element/id-in-node-list-index01.html: Added.
2009-11-29  Shu Chang  <Chang.Shu@nokia.com>

        Reviewed by Eric Seidel.

        Continue to search for matching node in the case where multiple nodes
        have the same id.
        https://bugs.webkit.org/show_bug.cgi?id=31428

        Test: fast/dom/Element/id-in-node-list-index01.html

        * dom/DynamicNodeList.cpp:
        (WebCore::DynamicNodeList::itemWithName):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51471 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/Element/id-in-node-list-index01-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Element/id-in-node-list-index01.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/DynamicNodeList.cpp

index c8a3becc9fb9a12d92c03042a68a91b978f63df5..56d6d2951ae9af7a9261542293e6d517bdc29e42 100644 (file)
@@ -1,3 +1,13 @@
+2009-11-29  Shu Chang  <Chang.Shu@nokia.com>
+
+        Reviewed by Eric Seidel.
+
+        Test using Id as index of node list.
+        https://bugs.webkit.org/show_bug.cgi?id=31428
+
+        * fast/dom/Element/id-in-node-list-index01-expected.txt: Added.
+        * fast/dom/Element/id-in-node-list-index01.html: Added.
+
 2009-11-28  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/LayoutTests/fast/dom/Element/id-in-node-list-index01-expected.txt b/LayoutTests/fast/dom/Element/id-in-node-list-index01-expected.txt
new file mode 100644 (file)
index 0000000..f36780d
--- /dev/null
@@ -0,0 +1,11 @@
+Test using id as index of node list
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS elems["id1"].getAttribute("name") is "name1"
+PASS elems["id2"].getAttribute("name") is "name2"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Element/id-in-node-list-index01.html b/LayoutTests/fast/dom/Element/id-in-node-list-index01.html
new file mode 100644 (file)
index 0000000..6b35841
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<div name='name1' id='id1'/>
+<p   name='name3' id='id2'/>
+<div name='name2' id='id2'/>
+
+<script>
+description("Test using id as index of node list");
+
+var elems = document.getElementsByTagName('div');
+
+shouldBe('elems["id1"].getAttribute("name")', '"name1"');
+shouldBe('elems["id2"].getAttribute("name")', '"name2"');
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 859d265d9db71ccdb17cf66f81c0dc9e73d7894e..09554fba0a9c3d999be8f518ec3eb9ef3c9e3e3e 100644 (file)
@@ -1,3 +1,16 @@
+2009-11-29  Shu Chang  <Chang.Shu@nokia.com>
+
+        Reviewed by Eric Seidel.
+
+        Continue to search for matching node in the case where multiple nodes
+        have the same id.
+        https://bugs.webkit.org/show_bug.cgi?id=31428
+
+        Test: fast/dom/Element/id-in-node-list-index01.html
+
+        * dom/DynamicNodeList.cpp:
+        (WebCore::DynamicNodeList::itemWithName):
+
 2009-11-29  Daniel Bates  <dbates@webkit.org>
 
         Reviewed by Eric Seidel.
index 892a5e7712381c2c26a810daf5b43840c53efa19..3f0744b88f94584620ecb7a2f191b3ee0b5b6d8d 100644 (file)
@@ -129,7 +129,9 @@ Node* DynamicNodeList::itemWithName(const AtomicString& elementId) const
                     return node;
             }
         }
-        return 0;
+        if (!node)
+            return 0;
+        // In the case of multiple nodes with the same name, just fall through.
     }
 
     unsigned length = this->length();