Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-conditional/container-queries/nested-size-style-container-invalidation.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Nested size/style @container-dependent elements respond to container size changes</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style>
#container {
container-type: size;
width: 1000px;
}
#container.narrow {
width: 600px;
}
#target {
color: red;
}
@container (width < 800px) {
@container style(--foo: bar) {
#target { color: green; }
}
}
</style>
<div id="container">
<div style="--foo: bar">
<div id="target">Green?</div>
</div>
</div>
<script>
setup(() => {
assert_implements_size_container_queries();
assert_implements_style_container_queries();
});
test(() => {
assert_equals(getComputedStyle(target).color, "rgb(255, 0, 0)");
}, "Initially red");
test(() => {
container.className = "narrow";
assert_equals(getComputedStyle(target).color, "rgb(0, 128, 0)");
}, "Green after reducing width");
</script>