typed-query-selector: Some `:is()` selectors are failing

I don’t know if it’s my override, but both of these are producing HTMLElement
:
const a = document.querySelector(`a.status-actions:is([href^="/"])`);
const b = document.querySelector(`a.status-actions:is(a[href^="/"])`);
I don’t know if I’m doing something wrong in my override:
This issue appeared after updating to TS 4.8 I think, as well as typed-query-selector v2.7
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (17 by maintainers)
Commits related to this issue
- fix whitespaces in `:is()` and `:where()` #26 — committed to g-plane/typed-query-selector by g-plane a year ago
I’ve rewritten the logic, and these inputs are supported:
:is(h1,h2):is(.c)
(previously this will cause OOM)You can inspect the tests: https://github.com/g-plane/typed-query-selector/commit/ff8b92c3fd1a23be4efbb60c4a2a01fc85d40736#diff-dd001b5fbb36c7c3308e20c616e78502244a6be3a772c85a58cb3d8e3f84d55f .
It should work better than before when parsing
:is()
and:where()
.New version will be released tomorrow. Note that
:is(h1,h2):is(.c)
isn’t supported due to OOM when type checking.This has been fixed in https://github.com/g-plane/typed-query-selector/commit/85119cd44d4522ab101645d0ce0d3ca9d1c8a9c6 .
Resolving tag name string to types is the last phase. Before that, it just processes strings, which is hard to be intercepted.
If the part to the left of the colon specifies a type
X
and the part inside parens specifies a typeY
, shouldn’tX & Y
be returned then? In this case,HTMLElement & HTMLAnchorElement
would simplify toHTMLAnchorElement
.It would be splitted into two parts:
*
anda
, and it can be hard to decide to select which one.Should they produce
HTMLAnchorElement
?