display-contents-dynamic-style-queries.html (1020B)
1 <!doctype html> 2 <title>CSS Container Queries Test: Invalidate style queries and display:contents</title> 3 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#style-container"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="support/cq-testcommon.js"></script> 7 <style> 8 #container.contents { 9 --foo: bar; 10 display: contents; 11 } 12 #target { 13 color: red; 14 } 15 @container style(--foo: bar) { 16 #target { 17 color: green; 18 } 19 } 20 </style> 21 <div id="container"> 22 <div id="target">This should be green</div> 23 </div> 24 <script> 25 setup(() => assert_implements_style_container_queries()); 26 27 test(() => { 28 assert_equals(getComputedStyle(target).color, "rgb(255, 0, 0)"); 29 }, "Initially the color is red"); 30 31 test(() => { 32 container.className = "contents"; 33 assert_equals(getComputedStyle(target).color, "rgb(0, 128, 0)"); 34 }, "After display and --foo changes, style() query causes the color to be green"); 35 </script>