-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove special :scope matching code in MatchForRelation
This special path causes :scope selectors to incorrectly match ':scope *' selectors in shadow roots, when it actually should match nothing [1]. The provided test scope-pseudo-in-shadow.html is passing in Firefox and Safari. The existing WPT scope-selector.html (all browsers currently passing) cover querySelector[All] cases well for shadow roots, document, and other DocumentFragments. There should be no behavior change there. Fixed: 378698644 [1] w3c/csswg-drafts#11188 [2] w3c/csswg-drafts#7261 Change-Id: I1efbf999864a766ad5dfaee1fd67527309e38107 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6011808 Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1382339}
- Loading branch information
1 parent
4523075
commit 46e8b76
Showing
2 changed files
with
27 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<title>:scope pseudo does not match in shadow root</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-scoping-1/#host-element-in-tree"> | ||
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11188"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<div id="host"></div> | ||
<script> | ||
test(() => { | ||
host.attachShadow({mode: 'open'}).innerHTML = ` | ||
<style> | ||
div { | ||
background-color: green; | ||
} | ||
:scope div { | ||
background-color: red; | ||
} | ||
:scope > div { | ||
background-color: red; | ||
} | ||
</style> | ||
<div>Test</div> | ||
`; | ||
let div = host.shadowRoot.querySelector('div'); | ||
assert_equals(getComputedStyle(div).backgroundColor, 'rgb(0, 128, 0)'); | ||
}, ':scope does not match in shadow root'); | ||
</script> |
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