Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:has(selector) matches nodes matched by selector #122

Open
mdjermanovic opened this issue Jun 25, 2021 · 0 comments
Open

:has(selector) matches nodes matched by selector #122

mdjermanovic opened this issue Jun 25, 2021 · 0 comments

Comments

@mdjermanovic
Copy link

esquery v1.4.0

const literal = espree.parse("1").body[0].expression;
const selector = esquery.parse(":has(Literal)");

esquery.matches(literal, selector); // true

Or. in the esquery demo, enter 1 as code, :has(Literal) as selector. It finds "Program", "ExpressionStatement", and "Literal".

I was expecting that selectors in :has() can match only descendants of the node, but in the above examples :has(Literal) matches a Literal node. Is this the intended behavior?

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

No branches or pull requests

1 participant