OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../resources/js-test.js"></script> | |
3 | |
4 <div id="sandbox"></div> | |
5 | |
6 <script> | |
7 description("Should update distribution when needed for querySelector and relate d methods."); | |
8 | |
9 function test(fn) | |
10 { | |
11 var sandbox = document.getElementById("sandbox"); | |
12 | |
13 sandbox.innerHTML = "<div id=host><div id=a><div id=b></div></div>"; | |
14 host = document.getElementById("host"); | |
15 hostRoot = host.createShadowRoot(); | |
16 hostRoot.innerHTML = "<div id=c><content></content></div>"; | |
17 | |
18 a = document.getElementById("a"); | |
19 b = document.getElementById("b"); | |
20 | |
21 aRoot = a.createShadowRoot(); | |
22 aRoot.innerHTML = "<div id=d><div id=e></div></div>"; | |
23 | |
24 c = hostRoot.getElementById("c"); | |
25 d = aRoot.getElementById("d"); | |
26 e = aRoot.getElementById("e"); | |
27 | |
28 sandbox.appendChild(host); | |
29 | |
30 fn(); | |
31 | |
32 sandbox.innerHTML = ""; | |
33 } | |
34 | |
35 function toArray(list) | |
36 { | |
37 return Array.prototype.slice.call(list); | |
38 } | |
39 | |
40 test(function() { | |
41 shouldBe("aRoot.querySelector(':host-context(#c) #d')", "d"); | |
42 }); | |
43 test(function() { | |
44 shouldBe("toArray(aRoot.querySelectorAll(':host-context(#c) #d'))", "[d]"); | |
45 }); | |
46 test(function() { | |
47 shouldBeNull("hostRoot.querySelector('::content #a')"); | |
hayato
2015/05/26 02:29:18
This should match, shouldn't this?
rune
2015/05/26 05:26:04
querySelector(All) would traverse descendants of h
| |
48 }); | |
49 test(function() { | |
50 shouldBe("toArray(hostRoot.querySelectorAll('::content #a'))", "[]"); | |
51 }); | |
52 test(function() { | |
53 shouldBeFalse("a.matches('::content #a')"); | |
54 }); | |
55 test(function() { | |
56 shouldBeTrue("d.matches(':host-context(#host) #d')"); | |
57 }); | |
58 test(function() { | |
59 shouldBeTrue("d.matches(':host-context(#c) #d')"); | |
60 }); | |
61 test(function() { | |
62 shouldBeNull("b.closest('::content #a')"); | |
63 }); | |
64 test(function() { | |
65 shouldBe("e.closest(':host-context(#host) #d')", "d"); | |
66 }); | |
67 </script> | |
OLD | NEW |