Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-mixins/contents-nested-declarations.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<head>
<title>CSS Mixins: @contents rules become nested declarations</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<style>
@mixin --m1(@contents) {
@contents;
}
#e1::after {
content: "AFTER";
@apply --m1 {
color: green;
}
}
</style>
<div id="e1"></div>
<script>
test(() => {
assert_equals(getComputedStyle(e1, '::after').color, 'rgb(0, 128, 0)');
}, 'Can mix declarations into pseudo-elements via @contents');
</script>
<style>
@mixin --m2(@contents) {
@contents;
}
/* Should match <div id=e2> with the specificity of :where(#e2) (zero),
not with the specificity of :is(:where(#e2), #u1). */
:where(#e2), #u1 {
@apply --m2 {
color: red;
}
}
:where(#e2) {
color: green; /* Wins. */
}
</style>
<div id="e2"></div>
<script>
test(() => {
assert_equals(getComputedStyle(e2).color, 'rgb(0, 128, 0)');
}, 'Nested declarations from @contents have top-level specificity behavior');
</script>
</body>
</html>