Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>Matching of child-indexed pseudo-classes</title> | |
| 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:ecoal95@gmail.com"> | |
| 5 <link rel="help" href="https://drafts.csswg.org/selectors-4/#child-index"> | |
| 6 <script src=../../resources/testharness.js></script> | |
| 7 <script src=../../resources/testharnessreport.js></script> | |
| 8 <script> | |
| 9 test(function() { | |
| 10 var check = function(element, selectors) { | |
| 11 for (var i = 0; i < selectors.length; ++i) { | |
| 12 var selector = selectors[i][0]; | |
| 13 var expected = selectors[i][1]; | |
| 14 assert_equals(expected, element.matches(selector), | |
| 15 "Expected " + element.tagName + " element to " + | |
| 16 (expected ? "match " : "not match ") + selector); | |
| 17 } | |
| 18 } | |
| 19 | |
| 20 var rootOfSubtreeSelectors = [ | |
| 21 [ ":first-child", true ], | |
| 22 [ ":last-child", true ], | |
|
rune
2017/01/18 21:33:19
Test :only-child as well?
emilio
2017/01/18 23:33:07
Yeah, tested that and :only-of-type too, and query
| |
| 23 [ ":first-of-type", true ], | |
| 24 [ ":last-of-type", true ], | |
| 25 [ ":nth-child(1)", true ], | |
| 26 [ ":nth-child(n)", true ], | |
| 27 [ ":nth-last-child(1)", true ], | |
| 28 [ ":nth-last-child(n)", true ], | |
| 29 [ ":nth-of-type(1)", true ], | |
| 30 [ ":nth-of-type(n)", true ], | |
| 31 [ ":nth-last-of-type(1)", true ], | |
| 32 [ ":nth-last-of-type(n)", true ], | |
| 33 [ ":nth-child(2)", false ], | |
| 34 [ ":nth-last-child(2)", false], | |
| 35 [ ":nth-of-type(2)", false ], | |
| 36 [ ":nth-last-of-type(2)", false], | |
| 37 ]; | |
| 38 | |
| 39 check(document.documentElement, rootOfSubtreeSelectors); | |
| 40 check(document.createElement('div'), rootOfSubtreeSelectors); | |
| 41 }, "child-indexed pseudo-classes should match without a parent") | |
| 42 </script> | |
| OLD | NEW |