summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-contain/container-queries/reattach-container-with-dirty-child.html
blob: 680d9caa84aed511f2e3a961e687a8b28a7c9e92 (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
<!doctype html>
<title>CSS Container Queries Test: @container changing display type while descendant styles change</title>
<link rel="help" href="https://drafts.csswg.org/css-contain-3/#size-container">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style>
  #container {
    container-type: inline-size;
  }
  @container (min-width: 200px) {
    div { color: red }
  }
  @container (max-width: 150px) {
    div { color: lime }
  }
</style>
<div id="container">
  <div id="child"><span id="inner">XXX</span></div>
</div>
<script>
  setup(() => assert_implements_container_queries());

  test(() => {
    container.offsetTop;
    assert_equals(getComputedStyle(child).color, "rgb(255, 0, 0)");
  }, "Initially wider than 200px");

  test(() => {
    container.style.width = "100px";
    container.style.display = "inline-block";
    inner.style.color = "green";
    container.offsetTop;
    assert_equals(getComputedStyle(child).color, "rgb(0, 255, 0)");
    assert_equals(getComputedStyle(inner).color, "rgb(0, 128, 0)");
  }, "Container query changed and inner.style applied");
</script>