OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <link rel="help" href="http://dom.spec.whatwg.org/#interface-nonelementparentnod
e"> |
| 5 <script src="../../../resources/js-test.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <div id="notInFragment"></div> |
| 9 <div id="duplicateId1"></div> |
| 10 <script> |
| 11 description("Tests that getElementById() API is exposed on DocumentFragment node
s."); |
| 12 |
| 13 var fragment = new DocumentFragment(); |
| 14 var div = document.createElement("div"); |
| 15 div.id = "divID"; |
| 16 fragment.appendChild(div); |
| 17 var a = document.createElement("a"); |
| 18 a.id = "aID"; |
| 19 div.appendChild(a); |
| 20 var span = document.createElement("span"); |
| 21 span.id = "duplicateId1"; |
| 22 div.appendChild(span); |
| 23 var h1 = document.createElement("h1"); |
| 24 h1.id = "duplicateId2"; |
| 25 div.appendChild(h1); |
| 26 var h2 = document.createElement("h2"); |
| 27 h2.id = "duplicateId2"; |
| 28 div.appendChild(h2); |
| 29 |
| 30 shouldBe("fragment.getElementById('divID')", "div"); |
| 31 shouldBe("fragment.getElementById('aID')", "a"); |
| 32 shouldBeNull("fragment.getElementById('notInFragment')"); |
| 33 shouldBeNull("fragment.getElementById('doesNotExist')"); |
| 34 |
| 35 // Duplicate ID cases. |
| 36 shouldBe("fragment.getElementById('duplicateId1')", "span"); // Should return th
e Element *inside* the DocumentFragment. |
| 37 shouldBe("fragment.getElementById('duplicateId2')", "h1"); // Should return the
first matching Element in case of duplicate. |
| 38 </script> |
| 39 </body> |
| 40 </html> |
OLD | NEW |