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

Screen Shot 7

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:

https://github.com/refined-github/refined-github/blob/65c58aed2ceb98e50c9112e7ef0428821033742e/source/helpers/types.d.ts#L5:L5

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

Most upvoted comments

I’ve rewritten the logic, and these inputs are supported:

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.

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 type Y, shouldn’t X & Y be returned then? In this case, HTMLElement & HTMLAnchorElement would simplify to HTMLAnchorElement.

It would be splitted into two parts: * and a, and it can be hard to decide to select which one.

Should they produce HTMLAnchorElement?