Closed Bug 1774588 Opened 3 years ago Closed 2 years ago

Add relative selector parsing for :has(> a)

Categories

(Core :: CSS Parsing and Computation, task)

task

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: tlouw, Assigned: dshin)

References

Details

Attachments

(1 file)

The :has selector only parses combinator selectors that has a type selector, e.g. p > a, but supports syntax like: :has(> a) which doesn't have the type selector.

Suggested fix is to fake the selector that is parsed to prepend the type of the :has element

Blocks: has-pseudo
Assignee: nobody → tlouw
Status: NEW → ASSIGNED

(In reply to Tiaan Louw from comment #0)

Suggested fix is to fake the selector that is parsed to prepend the type of the :has element

Sorry for my ignorance as I have no idea how the parser actually works, but doesn't parsing relative selectors mean to start parsing expecting a combinator first?

Matching is a whole different beast, of course.
I'd expect it to work as if the selectors inside :has() wheren't surrounded by it. E.g. p:has(> a, > .class) + p would first match p > a and p > .class and remember the <p> elements matched by them. Then p + p is matched against the remembered ps.

And is this bug meant to cover both or only the parsing?

Sebastian

Flags: needinfo?(tlouw)

My apologies, I admit my comment is a bit light on details.

Sorry for my ignorance as I have no idea how the parser actually works, but doesn't parsing relative selectors mean to start parsing expecting a combinator first?

We don't handle relative selectors normally, because of marching, so we need to make :has an exception. Basically we plan to represent relative selector syntax by having a magic placeholder of sorts that represents the :has scope, but we don't serialize it. It follows a similar pattern used for the ::slotted selector.

And is this bug meant to cover both or only the parsing?

This would only be for the parsing part.

Flags: needinfo?(tlouw)
Duplicate of this bug: 1813321
Assignee: tlouw → dshin
Blocks: 1820835
Pushed by dshin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3cf730621972 Parsing for relative selectors in `:has()`. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
Duplicate of this bug: 1771692
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: