Skip to content

Support :is() and :where() as aliases of :matches() #136

Open

Description

@gravitypdf-bot

Problem

Neither engine supports :is(), the CSS Selectors 4 name for :matches(), nor :where(), which matches the same way but contributes no specificity (QueryPath doesn't use specificity, so it is an alias here too):

$xml = '<?xml version="1.0"?><ul><li id="a"/><li id="b"/></ul>';

qp($xml)->find('li:matches(#b)');  // b
qp($xml)->find('li:is(#b)');       // QueryPath\CSS\ParseException: Unknown Pseudo-Class: is
qp($xml)->find(':where(#b)');      // QueryPath\CSS\ParseException: Unknown Pseudo-Class: where

Proposal

Treat is and where as matches in CSS\DOMTraverser\PseudoClass, and add them to Util::SELECTOR_ARGUMENT_PSEUDO_CLASSES so a positional argument (:is(:first)) is applied to the set as it is for :matches(). Since #127 the legacy QueryPathEventHandler no longer backs any QueryPath method, so it can be left alone.

Raised in #123 and deferred from #127.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions