Skip to content

Conversation

@richsilv
Copy link
Contributor

@richsilv richsilv commented Dec 6, 2022

Fixes #132, allowing users to write selectors with naked binary operators inside blocks, like FunctionExpression:has(> [name="foo"]).

This is achieved in two steps:

  1. Update to the Peg.js grammar.
  2. Handling the case of a missing left-hand selector inside a has block, by injecting a selector corresponding to the node which is then sub-traversed, using a new exactNode type.

@moniuch
Copy link

moniuch commented Mar 11, 2023

I would love this PR to get a review from the maintainers...

}

selector
= a:sequence ops:(binaryOp sequence)* {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too permissive. Instead, I would have just allowed an optional binaryOp in the has production.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can’t go directly in the has production, because that would cause problems if the second alternative has a root operator (:has(> a, > b)). I have resolved this in #145

@AustinGrey
Copy link

@richsilv Is there any appetite for addressing the reviewer's comments and resubmitting? This downstream affects ts-query which I need for another project, and I unfortunately do not know pegjs to try and submit my own PR.

@michaelficarra
Copy link
Member

fixed by #145

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.

:has(> child) is not supported

5 participants