| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/id-fastpath.js"></script> | 7 <script> |
| 8 description( |
| 9 "This tests that the querySelector and querySelectorAll fast path for IDs is not
overzelous." |
| 10 ); |
| 11 |
| 12 var root = document.createElement('div'); |
| 13 var correctNode = document.createElement('div'); |
| 14 correctNode.setAttribute("id", "testid") |
| 15 root.appendChild(correctNode); |
| 16 document.body.appendChild(root); |
| 17 |
| 18 shouldBe("document.querySelector('div#testid')", "correctNode"); |
| 19 shouldBe("document.querySelector('#testid')", "correctNode"); |
| 20 shouldBeNull("document.querySelector('ul#testid')"); |
| 21 shouldBeNull("document.querySelector('ul #testid')"); |
| 22 shouldBeNull("document.querySelector('#testid[attr]')"); |
| 23 shouldBeNull("document.querySelector('#testid:not(div)')"); |
| 24 |
| 25 shouldBe("document.querySelectorAll('div#testid').length", "1"); |
| 26 shouldBe("document.querySelectorAll('div#testid').item(0)", "correctNode"); |
| 27 shouldBe("document.querySelectorAll('#testid').length", "1"); |
| 28 shouldBe("document.querySelectorAll('#testid').item(0)", "correctNode"); |
| 29 shouldBe("document.querySelectorAll('ul#testid').length", "0"); |
| 30 shouldBe("document.querySelectorAll('ul #testid').length", "0"); |
| 31 shouldBe("document.querySelectorAll('#testid[attr]').length", "0"); |
| 32 shouldBe("document.querySelectorAll('#testid:not(div)').length", "0"); |
| 33 </script> |
| 8 </body> | 34 </body> |
| 9 </html> | 35 </html> |
| OLD | NEW |