Skip to content

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

Description

@mdjermanovic

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions