Skip to content

fix :has() with chained relative combinators - #156

Open
brettz9 wants to merge 1 commit into
estools:masterfrom
brettz9:has
Open

fix :has() with chained relative combinators#156
brettz9 wants to merge 1 commit into
estools:masterfrom
brettz9:has

Conversation

@brettz9

@brettz9 brettz9 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

fix :has() with chained relative combinators; fixes #152 ; closes #148

Claude AI suggested changes.

 estools#148

hasSelector previously parsed a leading combinator (e.g. `> A > B`)
by taking the whole remainder as an independent selector and
wrapping it once with exactNode, producing a right-nested structure
instead of the left-associative chain used by top-level selectors.
This caused false negatives (`X:has(> A > B)` not matching valid
nested structures) and false positives (matching when the :has()
subject itself satisfied an inner constraint).

Rebuild the chain the same way the `selector` rule does, seeding
the left-associative fold with exactNode for the leading combinator.

Regenerate parser.js from grammar.pegjs and add regression tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: X > Y > Z matches Z, but X:has(> Y > Z) does not match X

1 participant