forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[css-nesting] Make & in top-level rules behave like :scope.
This was a recent and seemingly unannounced change to the spec. Bug: 1095675 Change-Id: I9fec6ffe2f7f48ad1505772578127ad160038956 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4206786 Commit-Queue: Steinar H Gunderson <[email protected]> Reviewed-by: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1100352}
- Loading branch information
1 parent
cfdf7a3
commit c82c735
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,5 @@ | |
<div class="test"></div> | ||
<div class="test"></div> | ||
<div class="test"></div> | ||
<div class="test"></div> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!doctype html> | ||
<title>Top-level & is treated like :scope</title> | ||
<link rel="author" title="Steinar H. Gunderson" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/css-nesting-1/"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<div id="p"> | ||
<div class="match" id="level1"> | ||
<div class="match" id="level2"></div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
test(() => { | ||
let matched = []; | ||
for (const elem of p.querySelectorAll('& .match')) { | ||
matched.push(elem.getAttribute('id')); | ||
} | ||
assert_array_equals(matched, ['level1', 'level2']); | ||
}, '& as direct ancestor'); | ||
|
||
test(() => { | ||
let matched = []; | ||
for (const elem of p.querySelectorAll('& > .match')) { | ||
matched.push(elem.getAttribute('id')); | ||
} | ||
assert_array_equals(matched, ['level1']); | ||
}, '& matches scoped element only, not everything'); | ||
</script> |