Web-Facing Change PSA: The '&' pseudo-class behaves as :where(:scope) in @scope rules

10 views
Skip to first unread message

Anders Hartvoll Ruud

unread,
6:29 AM (8 hours ago) 6:29 AM
to blink-dev

Contact emails

and...@chromium.org


Specification

None


However, PR: https://github.com/w3c/csswg-drafts/pull/12914


Summary

The '&' pseudo-class now behaves like :where(:scope) (i.e. refers to the scoping root), rather than referring to the <scope-start> selector.


Miriam Suzanne wrote a blog post explaining about this change: https://css.oddbird.net/scope/parent-selector/


Blink component

Blink>CSS


Web Feature ID

Missing feature




Risks



Interoperability and Compatibility

This is theoretically a breaking change, and while @scope isn't widely used yet, I added a use-counter for this which recently hit stable: https://chromestatus.com/metrics/feature/timeline/popularity/5629 (~0.00016%)


Note: The use-counter triggers whenever '&' is seen in @scope at all. It does not mean that this change will actually cause an observable difference in the result for all of those 0.00016%.


The possibly breaking cases would be:


A) Here, the ‘&’ rule wins today, but will now lose against :where(:scope) due the change in specificity.


@scope (.foo) {

  & { color: green; } /* Used to win; now loses. */

  :where(:scope) { color: red; }

}


B) Since ‘&’ now refers to a specific element rather than a selector, selectors like the following can not match (since an element can not be its own sibling), whereas they previously could match:


@scope (.foo) {

  & + & { color: green; } /* Cannot match anything anymore. */

}


Gecko: Positive (https://github.com/web-platform-tests/wpt/pull/53831) Mozilla initiated the WPT change. (And the spec change.)


WebKit: Shipped/Shipping (https://github.com/WebKit/WebKit/commit/4d5ebef83e17f6201e006f379de304fac6d196b4)


Web developers: No signals


Other signals:


WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

No change.


Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?

Yes


Is this feature fully tested by web-platform-tests?

Yes

scope-invalidation.html
scope-name-defining-rules.html

scope-specificity.html


Flag name on about://flags



Finch feature name

CSSScopeifiedParentPseudoClass


Rollout plan

Will ship enabled for all users


Tracking bug

https://issues.chromium.org/issues/445949406


Estimated milestones

M143


Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5736934890668032?gate=6189707524440064


Note: This is a “Web-Facing Change” due to the API being changed in a trivial way with very low risk of breakage.


This intent message was generated by Chrome Platform Status.


Mike Taylor

unread,
9:01 AM (5 hours ago) 9:01 AM
to Anders Hartvoll Ruud, blink-dev

On 10/8/25 6:28 a.m., Anders Hartvoll Ruud wrote:

Contact emails

and...@chromium.org


Specification

None


However, PR: https://github.com/w3c/csswg-drafts/pull/12914

Thanks for doing this work. It's a bit surprising to me that other vendors are changing tests, implementations, and MDN articles before spec language has even landed. 
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAKFBnUpv5y%2BOf3ET5Mz6r1YT4WRuGT4zf-WpS7Z9zsOh3tDxeQ%40mail.gmail.com.

Anders Hartvoll Ruud

unread,
9:28 AM (5 hours ago) 9:28 AM
to Mike Taylor, blink-dev
Correction: scope-name-defining-rules.html should have been https://wpt.fyi/results/css/css-cascade/scope-nesting.html. (I copied the wrong link; scope-name-defining-rules.html is not relevant here.)
Note also that this change landed only a few hours ago (behind a flag). At the time of writing, wpt.fyi has not picked up that change, and shows red boxes for the tests above.
Reply all
Reply to author
Forward
0 new messages