@scope roots that differ only by an attribute value resolve to the same scope between siblings
Categories
(Core :: CSS Parsing and Computation, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox159 | --- | fixed |
People
(Reporter: arifdewi.uae, Assigned: dshin)
References
(Blocks 1 open bug)
Details
Attachments
(3 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36
Steps to reproduce
Load this page in Firefox:
<!doctype html>
<style>
@scope ([data-module="a"]) { .row { color: rgb(10, 10, 10); } }
@scope ([data-module="b"]) { .row { color: rgb(20, 20, 20); } }
</style>
<section data-module="a"><p class="row">first</p></section>
<section data-module="b"><p class="row">second</p></section>
Actual results
Actual results:
Both paragraphs compute color: rgb(10, 10, 10). The second section is styled
by the first section's @scope block; its own block never applies.
Expected results
Expected results:**
The first paragraph is rgb(10, 10, 10) and the second is rgb(20, 20, 20).
Chromium 153 and WebKit 26.6 both do this.
Additional information:
Three conditions are needed together; changing any one of them gives the
correct result:
- The two scoping roots are siblings. Nesting the second section inside
the first is correct. - The two root elements are otherwise indistinguishable: same tag name and
same class list. Giving them different classes is correct, and so is giving
them different tag names. Giving them differentids is not — it still
reproduces. - The roots are selected by attribute value. Using
.a/.bas the
scoping roots is correct.
Adding a lower boundary (to ([data-module])) does not change the outcome, and
neither does wrapping the rules in @layer, nor delivering the two blocks in
separate stylesheets via <link>, @import or adoptedStyleSheets.
Reproduced on Firefox 156.0 (release, macOS 26.6.2) and Firefox 155 (Playwright
build, headless). Not reproduced on Chromium 153.0.8010.12 or WebKit 26.6.
This pattern — one stylesheet per component, each scoped to
[data-component="<name>"] — is a natural way to use @scope, and the failure
is silent: the component is simply styled as its neighbour, with nothing
logged.
Comment 1•22 days ago
|
||
Seems like we're incorrectly sharing styles between them. This code is supposed to prevent it afaict.
Maybe we should disable cousin sharing across scope boundaries instead? WDYT David?
| Assignee | ||
Updated•22 days ago
|
Guys, just in case it might be helpful - attached more test cases. gecko-scope-probe2.html
| Assignee | ||
Comment 4•21 days ago
|
||
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/63045 for changes under testing/web-platform/tests
Comment 7•18 days ago
|
||
| bugherder | ||
Upstream PR merged by moz-wptsync-bot
Updated•4 days ago
|
Description
•