summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/selectors/is-nested.html
blob: 0658f9030d1303e46184741b5e4114c4ce7b40a4 (plain)
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
<!DOCTYPE html>
<html>
  <head>
    <title>CSS Selectors: :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 when nested">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <style>
      /* Testing that highest specificity is chosen for class outside of :is() */
      .a+.b+.c>.e+.d {
        color: black;
        font-size: 10px;
        width: 10px;
      }
      .e:is(.b+.f, .e:is(*, .c>.e, .g, *))+.d {
        color: red;
        font-size: 20px;
      }
      .a+.b+.c>.e+.d {
        color: yellow;
      }
      /* Testing specificty of a class within :is() */
      .a+.c>.e {
        color: black;
      }
      .e:is(.b+.f, :is(.c>.e, .g)) {
        color: red;
      }
      .c>.e {
        color: black;
      }
    </style>
  </head>
  <body>
    <div class="a">
    </div>
    <div class="b" id="b2">
    </div>
    <div class="c" id="c2">
      <div class="e">
      </div>
      <div class="d" id="d1">
        Yellow
      </div>
    </div>
    <div class="a">
    </div>
    <div class="c" id="c2">
      <div class="e" id="e1">
        Red
      </div>
    </div>
    <script>

      var red = "rgb(255, 0, 0)";
      var yellow = "rgb(255, 255, 0)";

      test(() => {
        assert_equals(getComputedStyle(d1).color, yellow);
        assert_equals(getComputedStyle(d1).fontSize, "20px");
        assert_equals(getComputedStyle(d1).width, "10px");
      }, "Test nested :is() chooses highest specificity for class outside :is().");

      test(() => {
        assert_equals(getComputedStyle(e1).color, red);
      }, "Test nested :is() specificity for class within arguments.");

    </script>
  </body>
</html>