Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-cascade/scope-overlapping-has.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>@scope - Overlapping scopes with :has(..:scope..) selector</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
:where(*) {
background-color: green;
}
@scope (.a) to (.limit) {
:scope:has(.b:not(:scope .a *)) .hello {
background-color: red;
}
}
</style>
<div class=a id=outer>
<div>
<div class=limit>
<div class=a id=inner>
<div class=b></div>
<div class=hello id=first>hello</div>
</div>
</div>
</div>
<div class=hello id=second>hello</div>
</div>
<script>
test(() => {
assert_equals(getComputedStyle(first).backgroundColor, 'rgb(255, 0, 0)');
assert_equals(getComputedStyle(second).backgroundColor, 'rgb(0, 128, 0)');
}, ':has() with inner :scope works when scopes overlap');
</script>