Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 2 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-cascade/scope-import-parent-pseudo.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>@import scope(), '&' selectors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
@import url("resources/scope-imported.css") scope((.scope));
</style>
<main id=main>
<div class=scope>
<div class=w>Inside</div>
<div class=scope>
<div class=w>Inner (W)</div>
<div class=u>Inner (U)</div>
</div>
</div>
</main>
<script>
test(() => {
let e = main.querySelector('#main > .scope > .w');
assert_equals(getComputedStyle(e).getPropertyValue('--w'), '1');
}, 'The & selector matches the scoping root');
test(() => {
let w = main.querySelector('#main > .scope > .scope > .w');
assert_equals(getComputedStyle(w).getPropertyValue('--w'), '1');
// The '& > & > .u' selector should behave like ':scope > :scope > .u'
// and therefore never match.
let u = main.querySelector('#main > .scope > .scope > .u');
assert_equals(getComputedStyle(u).getPropertyValue('--u'), '');
}, 'The & selector behaves like :scope');
</script>