File: is.html

package info (click to toggle)
firefox 147.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,324 kB
  • sloc: cpp: 7,607,156; javascript: 6,532,492; ansic: 3,775,158; python: 1,415,368; xml: 634,556; asm: 438,949; java: 186,241; sh: 62,751; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (161 lines) | stat: -rw-r--r-- 4,361 bytes parent folder | download | duplicates (2)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html>
  <head>
    <title>CSS Selectors Invalidation: :is()</title>
    <link rel="author" title="Victoria Su" href="mailto:victoriaytsu@google.com">
    <link rel="help" href="https://drafts.csswg.org/selectors-4/#matches">
    <meta name="assert" content="This tests that the :is() selector is effective">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <style>
      .b {
        color: yellow;
      }
      /*Simple selector arguments */
      .a :is(.b, .c) {
        color: red;
      }
      /*Compound selector arguments */
      .a :is(.c#d, .e) {
        color: green;
      }
      /* Complex selector arguments */
      .a .g>.b {
        color: black;
      }
      .a :is(.e+.f, .g>.b, .h) {
        color: blue;
      }
      .g>.b {
        color: black;
      }
      .a .h {
        color: black;
      }
      /* Nested */
      .a+.c>.e {
        color: black;
      }
      .c>.a+.e {
        color: black;
      }
      .a+:is(.b+.f, :is(.c>.e, .g)) {
        color: red;
      }
      .c>.e {
        color: black;
      }
      /* Non-Subject Compound */
      .a:is(.b *) .c{
        color: blue;
      }
    </style>
  </head>
  <body>
    <div id="a1">
      <div class="b" id="b1">
        Red
      </div>
      <div class="c" id="c1">
        Red
      </div>
      <div class="c" id="d">
        Green
      </div>
      <div class="e" id="e1">
        Green
      </div>
      <div class="f" id="f1">
        Blue
      </div>
      <div class="g">
        <div class="b" id="b2">
          Blue
          <div class="b" id="b3">
            Red
          </div>
        </div>
      </div>
      <div class="h" id="h1">
        Blue
      </div>
    </div>
    <div class="c" id="c2">
      <div id="a2"></div>
      <div class="e" id="e2">
        Red
      </div>
    </div>
    <div id=b4>
      <div>
        <div class=a>
          <div class=c id="c3">
            Blue
          </div>
        </div>
      </div>
    </div>
    <script>
      document.body.offsetTop;

      var black = "rgb(0, 0, 0)";
      var blue = "rgb(0, 0, 255)";
      var green = "rgb(0, 128, 0)";
      var red = "rgb(255, 0, 0)";
      var yellow = "rgb(255, 255, 0)";

      test(() => {
        assert_equals(getComputedStyle(b1).color, yellow);
        assert_equals(getComputedStyle(b2).color, black);
        assert_equals(getComputedStyle(b3).color, yellow);
        assert_equals(getComputedStyle(c1).color, black);
        assert_equals(getComputedStyle(d).color, black);
        assert_equals(getComputedStyle(e1).color, black);
        assert_equals(getComputedStyle(e2).color, black);
        assert_equals(getComputedStyle(f1).color, black);
        assert_equals(getComputedStyle(h1).color, black);
      }, "Preconditions.");

      test(() => {
        a1.className = "a";
        assert_equals(getComputedStyle(b1).color, red);
        assert_equals(getComputedStyle(b3).color, red);
        assert_equals(getComputedStyle(c1).color, red);
      }, "Invalidate :is() for simple selector arguments.");

      test(() => {
        a1.className = "a";
        assert_equals(getComputedStyle(d).color, green);
      }, "Invalidate :is() for compound selector arguments.");

      test(() => {
        a1.className = "a";
        assert_equals(getComputedStyle(b2).color, blue);
        assert_equals(getComputedStyle(b3).color, red);
        assert_equals(getComputedStyle(f1).color, blue);
      }, "Invalidate :is() for complex selector arguments.");

      test(() => {
        a1.className = "a";
        assert_equals(getComputedStyle(e2).color, black);
        a2.className = "a";
        assert_equals(getComputedStyle(e2).color, red);
      }, "Invalidate nested :is().");

      test(() => {
        a1.className = "a";
        assert_equals(getComputedStyle(b2).color, blue);
        assert_equals(getComputedStyle(h1).color, blue);
      }, "Test specificity of :is().");

      test(() => {
        b4.className = "b";
        assert_equals(getComputedStyle(c3).color, blue);
        b4.className = "";
        assert_equals(getComputedStyle(c3).color, red);
        b4.className = "b";
        assert_equals(getComputedStyle(c3).color, blue);
      }, "Invalidate :is() in non-subject compound");
    </script>
  </body>
</html>