File: after-change-style-inherited.html

package info (click to toggle)
thunderbird 1%3A140.3.1esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,608,628 kB
  • sloc: cpp: 7,671,698; javascript: 5,901,131; ansic: 3,898,955; python: 1,413,270; xml: 653,997; asm: 462,284; java: 180,948; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (178 lines) | stat: -rw-r--r-- 6,329 bytes parent folder | download | duplicates (8)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<title>CSS Transitions Test: trigger transitions on inherited after-change styles</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-1/#after-change-style">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
  #t1 :is(.outer, .inner) { transition: color 1000s steps(2, start); }
  #t1 .outer { color: red; }
  #t1 .inner { color: black; }
  #t1 .outer.green { color: lime; }
  #t1 .outer.green .inner { color: unset; }
</style>
<div id="t1">
  <div class="outer">
    <div>
      <div class="inner"></div>
    </div>
  </div>
</div>
<script>
  test(() => {
    const outer = document.querySelector("#t1 .outer");
    const inner = document.querySelector("#t1 .inner");
    outer.offsetTop;
    assert_equals(getComputedStyle(outer).color, "rgb(255, 0, 0)",
                  ".outer initially red");
    assert_equals(getComputedStyle(inner).color, "rgb(0, 0, 0)",
                  ".inner initially black");
    outer.classList.add("green");
    assert_equals(getComputedStyle(outer).color, "rgb(128, 128, 0)",
                  ".outer halfway between red and lime");
    assert_equals(getComputedStyle(inner).color, "rgb(0, 128, 0)",
                  ".inner halfway between black and lime");
  }, "Start .inner transition based on inherited after-change color from .outer (lime)");
</script>

<style>
  #t2 :is(.outer, .inner) { transition: background-color 1000s steps(2, start); }
  #t2 .outer { background-color: red; }
  #t2 .inner { background-color: black; }
  #t2 .outer.green { background-color: lime; }
  #t2 .outer.green div { background-color: inherit; }
</style>
<div id="t2">
  <div class="outer">
    <div>
      <div class="inner"></div>
    </div>
  </div>
</div>
<script>
  test(() => {
    const outer = document.querySelector("#t2 .outer");
    const inner = document.querySelector("#t2 .inner");
    outer.offsetTop;
    assert_equals(getComputedStyle(outer).backgroundColor, "rgb(255, 0, 0)",
                  ".outer initially red");
    assert_equals(getComputedStyle(inner).backgroundColor, "rgb(0, 0, 0)",
                  ".inner initially black");
    outer.classList.add("green");
    assert_equals(getComputedStyle(outer).backgroundColor, "rgb(128, 128, 0)",
                  ".outer halfway between red and lime");
    assert_equals(getComputedStyle(inner).backgroundColor, "rgb(0, 128, 0)",
                  ".inner halfway between black and lime");
  }, "Start .inner transition based on inherited after-change background-color from .outer (lime)");
</script>

<style>
  #t3 .trans {
    transition: 1000s steps(2, start);
    transition-property: color, word-spacing;
  }

  #t3 .a2 { color: red; }
  #t3 .a3 { color: black; }
  #t3 .a2.green { color: lime; }
  #t3 .a2.green .a3 { color: unset; }

  #t3 .a1 { word-spacing: 17px; }
  #t3 .a3 { word-spacing: 0px; }
  #t3 .a1.wide { word-spacing: 100px; }
  #t3 .a1.wide .a3 { word-spacing: unset; }
</style>
<div id="t3">
  <div class="trans a1">
    <div style="color:pink">
      <div class="trans a2">
          <div class="trans a3"></div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
  const a1 = document.querySelector("#t3 .a1");
  const a2 = document.querySelector("#t3 .a2");
  const a3 = document.querySelector("#t3 .a3");

  test(() => {
    assert_equals(getComputedStyle(a3).color, "rgb(0, 0, 0)", ".a3 color initially black");
    assert_equals(getComputedStyle(a3).wordSpacing, "0px", ".a3 word-spacing initially 0px");
  }, "Initial computed styles");

  test(() => {
    a1.classList.add("wide");
    a2.classList.add("green");
    assert_equals(getComputedStyle(a3).color, "rgb(0, 128, 0)", ".a3 color transitioning between black and lime");
    assert_equals(getComputedStyle(a3).wordSpacing, "50px", ".a3 word-spacing transitioning between 0px and 100px");
  }, "Start inner transitions based on inherited after-change color and word-spacing from two different ancestors");
</script>

<style>
  #t4 :is(.outer, .inner) { transition: color 1000s steps(2, start); }
  #t4 .outer { color: red; }
  #t4 .inner { color: black; }
  #t4 .outer.green { color: lime; }
  #t4 .outer.green .inner { color: unset; }
  @starting-style {
    #t4 .outer.green { color: pink; }
  }
</style>
<div id="t4">
  <div class="outer">
    <div>
      <div class="inner"></div>
    </div>
  </div>
</div>
<script>
  test(() => {
    const outer = document.querySelector("#t4 .outer");
    const inner = document.querySelector("#t4 .inner");
    outer.offsetTop;
    assert_equals(getComputedStyle(outer).color, "rgb(255, 0, 0)",
                  ".outer initially red");
    assert_equals(getComputedStyle(inner).color, "rgb(0, 0, 0)",
                  ".inner initially black");
    outer.classList.add("green");
    assert_equals(getComputedStyle(outer).color, "rgb(128, 128, 0)",
                  ".outer halfway between red and lime");
    assert_equals(getComputedStyle(inner).color, "rgb(0, 128, 0)",
                  ".inner halfway between black and lime");
  }, "@starting-style rules should not apply to after-change style");
</script>

<style>
  #t5 :is(.outer, .inner) { transition: color 1000s steps(2, start); }
  #t5 .outer { color: red; }
  #t5 .inner { color: black; }
  #t5 .outer.green { color: lime; }
  #t5 .container { container-type: inline-size; }
  @container (width < 100000px) {
    #t5 .outer.green .inner { color: unset; }
  }
</style>
<div id="t5">
  <div class="outer">
    <div class="container">
      <div class="inner"></div>
    </div>
  </div>
</div>
<script>
  test(() => {
    const outer = document.querySelector("#t5 .outer");
    const inner = document.querySelector("#t5 .inner");
    outer.offsetTop;
    assert_equals(getComputedStyle(outer).color, "rgb(255, 0, 0)",
                  ".outer initially red");
    assert_equals(getComputedStyle(inner).color, "rgb(0, 0, 0)",
                  ".inner initially black");
    outer.classList.add("green");
    assert_equals(getComputedStyle(outer).color, "rgb(128, 128, 0)",
                  ".outer halfway between red and lime");
    assert_equals(getComputedStyle(inner).color, "rgb(0, 128, 0)",
                  ".inner halfway between black and lime");
  }, "@container rules apply to after-change style");
</script>