blob: 717d60e919a229591df40f7dee030cf0103c2b1d [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<title>CSS Mixins: @contents fallbacks become nested declarations</title>
<link rel="help" href="https://drafts.csswg.org/css-mixins-1/#contents-rule">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<style>
@mixin --m1(@contents) {
@contents {
color: green;
}
}
#e1::after {
content: "AFTER";
@apply --m1;
}
</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 {
color: red;
}
}
/* 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;
}
: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>