-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathis-where-pseudo-containing-hard-pseudo-and-never-matching.html
80 lines (72 loc) · 2.26 KB
/
is-where-pseudo-containing-hard-pseudo-and-never-matching.html
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
<!DOCTYPE html>
<title>CSS Selectors Invalidation: :is and :where selectors containing "hard" selectors and selectors that never match</title>
<link rel="author" title="David Shin" href="dshin@mozilla.com">
<link rel="help" href="https://drafts.csswg.org/selectors/#logical-combination">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1942695">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.container {
color: grey;
}
#subject1:is(.container:has(.descendant):focus-within, .never-matches) {
color: red;
}
#subject2:where(.container:has(.descendant):focus-within, .never-matches) {
color: orangered;
}
#subject3:is(:nth-child(1 of .container):focus-within, .never-matches) {
color: darkred;
}
#subject4:where(:nth-child(1 of .container):focus-within, .never-matches) {
color: pink;
}
</style>
<div id="subject1" class="container">
<div class="descendant"></div>
<a id="anchor1" href="#">X</a>
</div>
<div id="subject2" class="container">
<div class="descendant"></div>
<a id="anchor2" href="#">X</a>
</div>
<div>
<div id="subject3" class="container">
<div class="descendant"></div>
<a id="anchor3" href="#">x</a>
</div>
</div>
<div>
<div id="subject4" class="container">
<div class="descendant"></div>
<a id="anchor4" href="#">x</a>
</div>
</div>
<script>
const colors = {
grey: "rgb(128, 128, 128)",
red: "rgb(255, 0, 0)",
orangered: "rgb(255, 69, 0)",
darkred: "rgb(139, 0, 0)",
pink: "rgb(255, 192, 203)",
};
function run_test(subject, anchor, before, after) {
const beforeColor = colors[before];
test(() => {
assert_equals(getComputedStyle(subject).color, beforeColor);
}, subject.id + " initial color is " + before);
anchor.focus();
const afterColor = colors[after];
test(() => {
assert_equals(getComputedStyle(subject).color, afterColor);
}, subject.id + " color after focus is " + after);
anchor.blur();
test(() => {
assert_equals(getComputedStyle(subject).color, beforeColor);
}, subject.id + " color after blur is " + before);
}
run_test(subject1, anchor1, "grey", "red");
run_test(subject2, anchor2, "grey", "orangered");
run_test(subject3, anchor3, "grey", "darkred");
run_test(subject4, anchor4, "grey", "pink");
</script>