Issue
When attempting to parse a CSS selector using a :has pseudo-class, it works but only if a singular tag name is provided.
For example, if selecting for a child with attributes:
>>> from cssselect import GenericTranslator
>>> GenericTranslator().css_to_xpath('h4.my-class:has(a[href^="/rel"])')
*** cssselect.parser.SelectorSyntaxError: Expected an argument, got <DELIM '[' at 17>
Likewise, if attempting to select for a tag with a descendant tag, we get:
>>> GenericTranslator().css_to_xpath('h4.my-class:has(div a')
*** cssselect.parser.SelectorSyntaxError: Expected an argument, got <IDENT 'a' at 20>
However, selecting for a singular tag name works:
>>> GenericTranslator().css_to_xpath('h4.my-class:has(a)')
"descendant-or-self::h4[(@class and contains(concat(' ', normalize-space(@class), ' '), ' my-class ')) and (descendant::a)]"
Diagnosing it further, this also does not affect combinators inside the :has(...):
>>> GenericTranslator().css_to_xpath('h4.my-class:has(> a)')
"descendant-or-self::h4[(@class and contains(concat(' ', normalize-space(@class), ' '), ' my-class ')) and (./a)]"
Information
Running cssselect version 1.5.0.
Issue
When attempting to parse a CSS selector using a
:haspseudo-class, it works but only if a singular tag name is provided.For example, if selecting for a child with attributes:
Likewise, if attempting to select for a tag with a descendant tag, we get:
However, selecting for a singular tag name works:
Diagnosing it further, this also does not affect combinators inside the
:has(...):Information
Running
cssselectversion1.5.0.