1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
<!DOCTYPE html>
<html>
<head>
<title>CSS Selectors Invalidation: :where()</title>
<link rel="author" title="Victoria Su" href="mailto:victoriaytsu@google.com">
<link rel="help" href="https://drafts.csswg.org/selectors-4/#zero-matches">
<meta name="assert" content="This tests that the :where() selector is effective">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
* {
color: black;
}
.b {
color: yellow;
}
/*Simple selector arguments */
:where(.b, .c) {
color: red;
}
/*Compound selector arguments */
.a~:where(.c#d, .e) {
color: green;
}
/* Complex selector arguments */
.h {
color: red;
}
:where(.a~.h, .a~.h+.f) {
color: yellow;
}
/* Nested */
:where(.a>:where(.g+.h, .b)~.i) {
color: blue;
}
:where(:is(.a~.h)) {
color: yellow;
}
</style>
</head>
<body>
<div id="a1">
<div class="g">
</div>
<div class="h">
</div>
<div class="i" id="i1">
Blue
</div>
</div>
<div class="b" id="b1">
Yellow
</div>
<div class="c" id="c1">
Red
</div>
<div class="c" id="d">
Green
</div>
<div class="h" id="h1">
Red
</div>
<div class="f" id="f1">
Yellow
</div>
<script>
document.body.offsetTop;
var black = "rgb(0, 0, 0)";
var green = "rgb(0, 128, 0)";
var red = "rgb(255, 0, 0)";
var yellow = "rgb(255, 255, 0)";
var blue = "rgb(0, 0, 255)";
test(() => {
assert_equals(getComputedStyle(b1).color, yellow);
assert_equals(getComputedStyle(c1).color, red);
assert_equals(getComputedStyle(d).color, red);
assert_equals(getComputedStyle(h1).color, red);
assert_equals(getComputedStyle(f1).color, black);
assert_equals(getComputedStyle(i1).color, black);
}, "Preconditions.");
test(() => {
a1.className = "a";
assert_equals(getComputedStyle(b1).color, yellow);
assert_equals(getComputedStyle(c1).color, red);
}, "Invalidate :where() for simple selector arguments.");
test(() => {
a1.className = "a";
assert_equals(getComputedStyle(d).color, green);
}, "Invalidate :where() for compound selector arguments.");
test(() => {
a1.className = "a";
assert_equals(getComputedStyle(h1).color, red);
assert_equals(getComputedStyle(f1).color, yellow);
}, "Invalidate :where() for complex selector arguments.");
test(() => {
a1.className = "a";
assert_equals(getComputedStyle(i1).color, blue);
}, "Invalidate nested :where().");
</script>
</body>
</html>
|