2 "This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) work with elements that are not in a document yet."
5 var root
= document
.createElement('div');
6 var correctNode
= document
.createElement('div');
7 correctNode
.setAttribute("id", "testId")
8 root
.appendChild(correctNode
);
9 var noChild
= document
.createElement('div');
11 shouldBe("root.querySelector('div')", "correctNode");
12 shouldBe("root.querySelector('#testId')", "correctNode");
14 shouldBe("root.querySelectorAll('div').length", "1");
15 shouldBe("root.querySelectorAll('div').item(0)", "correctNode");
16 shouldBe("root.querySelectorAll('#testId').length", "1");
17 shouldBe("root.querySelectorAll('#testId').item(0)", "correctNode");
19 shouldBeNull("noChild.querySelector('div')");
20 shouldBe("noChild.querySelectorAll('div').length", "0");
22 shouldBeTrue("correctNode.webkitMatchesSelector('div')");
23 shouldBeTrue("correctNode.webkitMatchesSelector('#testId')");