:has() pseudo-class crashes when used with CSS nesting
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
People
(Reporter: kizmarh, Assigned: emilio)
References
Details
Crash Data
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0
Steps to reproduce:
Visit https://codepen.io/kizu/pen/eYxEaVb or open the attached web page, or create a page with the following CSS: :has(*){:has(&){}}
Actual results:
The page crashes.
Expected results:
The page should not crash.
Now, this might be an interesting interop issue: in the specs (https://drafts.csswg.org/selectors/#relational) having the nested :has()
is not allowed
The :has() pseudo-class cannot be nested; :has() is not valid within :has().
However! While a regular nested :has()
like :has(> li:has(strong))
does not work (see https://codepen.io/kizu/pen/XWOaLgm), in both Safari and Chrome it actually works when nested via native CSS nesting! (opening the reported page in them renders the ul
with the lime background)
Comment 1•10 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::CSS Parsing and Computation' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Assignee | ||
Updated•10 months ago
|
Assignee | ||
Comment 2•10 months ago
|
||
For now, do the same as pseudo-elements, which is effectively to keep
them in the replaced selector but don't match them. Avoid crashing in
this case.
I filed https://github.com/w3c/csswg-drafts/issues/9600 since this issue
isn't specific about :has(), and depending on the result of that
discussion, the "proper" solution might be different.
Assignee | ||
Updated•10 months ago
|
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/69bede2c30ec Don't crash when finding nested relative selectors. r=dshin
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/43186 for changes under testing/web-platform/tests
Comment 5•10 months ago
|
||
bugherder |
Comment 6•10 months ago
|
||
bugherder |
Comment 7•10 months ago
|
||
bugherder |
Upstream PR merged by moz-wptsync-bot
Comment 10•10 months ago
|
||
Copying crash signatures from duplicate bugs.
Updated•10 months ago
|
Comment 11•10 months ago
|
||
Reproducible on a 2023-11-14 Nightly build on Ubuntu 22.
Verified as fixed on Firefox 121.0b3 and Nightly 122.0a1 on Ubuntu 22, Windows 10, macOS 12.
Description
•