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/style-query-registered-custom-removed-initial.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>CSS Container Queries Test: style() query matching registered custom property initial value</title>
<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#style-container">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style id="style_sheet">
@property --length {
syntax: "<length>";
initial-value: 30px;
inherits: true;
}
#container { container-name: --container; }
#target { color: lime; }
@container --container style(--length: 30px) {
#target { color: green; }
}
</style>
<div id="container">
<div id="target"></div>
</div>
<script>
setup(() => assert_implements_style_container_queries());
test(() => {
assert_equals(getComputedStyle(target).color, "rgb(0, 128, 0)");
}, "Query matching initial value of registered property");
test(() => {
style_sheet.sheet.deleteRule(0);
assert_equals(getComputedStyle(target).color, "rgb(0, 255, 0)");
}, "Query no longer matching initial value after @property rule is removed");
</script>