Closed Bug 1864647 Opened 10 months ago Closed 10 months ago

:has() pseudo-class crashes when used with CSS nesting

Categories

(Core :: CSS Parsing and Computation, defect)

Firefox 121
defect

Tracking

()

VERIFIED FIXED
121 Branch
Tracking Status
firefox121 --- verified
firefox122 --- verified

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)

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.

Component: Untriaged → CSS Parsing and Computation
Product: Firefox → Core
Assignee: nobody → emilio
Flags: needinfo?(emilio)

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.

Flags: needinfo?(emilio)
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
Status: UNCONFIRMED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch
Upstream PR merged by moz-wptsync-bot
Duplicate of this bug: 1864938

Copying crash signatures from duplicate bugs.

Crash Signature: [@ <style::invalidation::element::invalidation_map::RelativeSelectorInnerDependencyCollector as selectors::visitor::SelectorVisitor>::visit_relative_selector_list] [@ selectors::parser::Component<T>::visit]
Crash Signature: [@ <style::invalidation::element::invalidation_map::RelativeSelectorInnerDependencyCollector as selectors::visitor::SelectorVisitor>::visit_relative_selector_list] [@ selectors::parser::Component<T>::visit] → [@ <style::invalidation::element::invalidation_map::RelativeSelectorInnerDependencyCollector as selectors::visitor::SelectorVisitor>::visit_relative_selector_list] [@ selectors::parser::Component<T>::visit]
Flags: qe-verify+

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.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: