| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 | |
| 3 <script src="../../../resources/js-test.js"></script> | |
| 4 | |
| 5 <template id="item"> | |
| 6 <div id="host1"> | |
| 7 <span class="a">First</span> | |
| 8 <span class="b">Second</span> | |
| 9 </div> | |
| 10 </template> | |
| 11 | |
| 12 <template id="host1-shadow"> | |
| 13 <div id="host2"> | |
| 14 <content select=".b"></content> | |
| 15 <content select=".a"></content> | |
| 16 </div> | |
| 17 </template> | |
| 18 | |
| 19 <template id="host2-shadow"> | |
| 20 <content id="target"></content> | |
| 21 </template> | |
| 22 | |
| 23 <script> | |
| 24 // Creates the host/shadow templates described above which swap the nodes | |
| 25 // using distribution and then returns a string list of the classes of the | |
| 26 // elements that were distributed in order. | |
| 27 function testSelector(select) { | |
| 28 var host1 = document.getElementById("item").content.firstElementChild.cloneN
ode(true); | |
| 29 var template1 = document.getElementById("host1-shadow").content; | |
| 30 host1.createShadowRoot().appendChild(template1.cloneNode(true)); | |
| 31 | |
| 32 var host2 = host1.shadowRoot.getElementById("host2"); | |
| 33 var template2 = document.getElementById("host2-shadow").content; | |
| 34 host2.createShadowRoot().appendChild(template2.cloneNode(true)); | |
| 35 | |
| 36 var target = host2.shadowRoot.getElementById("target"); | |
| 37 target.select = select; | |
| 38 | |
| 39 var result = []; | |
| 40 var nodes = target.getDistributedNodes(); | |
| 41 for (var i = 0; i < nodes.length; ++i) | |
| 42 result.push(nodes[i].className); | |
| 43 | |
| 44 return result.join(","); | |
| 45 } | |
| 46 | |
| 47 description("Test the :not pseudo selector in <content select>"); | |
| 48 | |
| 49 shouldBeEqualToString("testSelector('span')", "b,a"); | |
| 50 shouldBeEqualToString("testSelector(':nth-child(1)')", "b"); | |
| 51 shouldBeEqualToString("testSelector(':nth-child(2)')", "a"); | |
| 52 shouldBeEqualToString("testSelector(':not(:nth-child(1))')", "a"); | |
| 53 shouldBeEqualToString("testSelector(':not(:nth-child(2))')", "b"); | |
| 54 </script> | |
| OLD | NEW |