2 "This tests that the querySelector and querySelectorAll fast path for IDs is not overzelous."
5 var root
= document
.createElement('div');
6 var correctNode
= document
.createElement('div');
7 correctNode
.setAttribute("id", "testid")
8 root
.appendChild(correctNode
);
9 document
.body
.appendChild(root
);
11 shouldBe("document.querySelector('div#testid')", "correctNode");
12 shouldBe("document.querySelector('#testid')", "correctNode");
13 shouldBeNull("document.querySelector('ul#testid')");
14 shouldBeNull("document.querySelector('ul #testid')");
15 shouldBeNull("document.querySelector('#testid[attr]')");
16 shouldBeNull("document.querySelector('#testid:not(div)')");
18 shouldBe("document.querySelectorAll('div#testid').length", "1");
19 shouldBe("document.querySelectorAll('div#testid').item(0)", "correctNode");
20 shouldBe("document.querySelectorAll('#testid').length", "1");
21 shouldBe("document.querySelectorAll('#testid').item(0)", "correctNode");
22 shouldBe("document.querySelectorAll('ul#testid').length", "0");
23 shouldBe("document.querySelectorAll('ul #testid').length", "0");
24 shouldBe("document.querySelectorAll('#testid[attr]').length", "0");
25 shouldBe("document.querySelectorAll('#testid:not(div)').length", "0");