4 <link rel=
"help" href=
"http://dom.spec.whatwg.org/#interface-nonelementparentnode">
5 <script src=
"../../../resources/js-test.js"></script>
8 <div id=
"notInFragment"></div>
9 <div id=
"duplicateId1"></div>
11 description("Tests that getElementById() API is exposed on DocumentFragment nodes.");
13 var fragment
= new DocumentFragment();
14 var div
= document
.createElement("div");
16 fragment
.appendChild(div
);
17 var a
= document
.createElement("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";
26 var h2
= document
.createElement("h2");
27 h2
.id
= "duplicateId2";
30 shouldBe("fragment.getElementById('divID')", "div");
31 shouldBe("fragment.getElementById('aID')", "a");
32 shouldBeNull("fragment.getElementById('notInFragment')");
33 shouldBeNull("fragment.getElementById('doesNotExist')");
35 // Duplicate ID cases.
36 shouldBe("fragment.getElementById('duplicateId1')", "span"); // Should return the Element *inside* the DocumentFragment.
37 shouldBe("fragment.getElementById('duplicateId2')", "h1"); // Should return the first matching Element in case of duplicate.