Skip to content

:has(> child) is not supported #132

@c-harding

Description

@c-harding

:has() expressions do not work with a leading >. This is included as the first example is the linked docs for :has from the readme (https://drafts.csswg.org/selectors-4/Overview.bs#relational).

I am trying to match the following code, specifically any call to router.push(router.resolve(...)).

    function onClick() {
      return router.push(
        router.resolve({
          name: "page1",
        })
      );
    }

This means that I need to check both descent paths of the CallExpression. I would like to match the call expression containing both of these children:

CallExpression > MemberExpression.callee[object.name=router][property.name=push] and CallExpression > CallExpression.arguments > MemberExpression.callee[object.name=router][property.name=resolve]

Ideally this could be achieved by

CallExpression:has(
  > MemberExpression.callee[object.name=router][property.name=push]
):has(
  > CallExpression.arguments > MemberExpression.callee[object.name=router][property.name=resolve]
)

If the leading > inside the :has() are omitted, this selector is too broad, also matching for example router.push(otherFunction(router.resolve({})).

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