Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CSS Selectors Level 4 selectors #5111

Open
mgol opened this issue Sep 7, 2022 · 0 comments
Open

Support CSS Selectors Level 4 selectors #5111

mgol opened this issue Sep 7, 2022 · 0 comments

Comments

@mgol
Copy link
Member

mgol commented Sep 7, 2022

Description

In 5.0.0, when we plan to utilize qSA for all selectors, avoiding custom traversal while still supporting most jQuery selector extensions, we should consider making sure CSS Selectors Level 4 work fine. This involves writing tests for these new selectors mixed with jQuery-specific extensions.

While the spec hasn't reached the W3C Recommendation status that CSS Selectors Level 3 has, some of the selectors there are wildly implemented so they are unlikely to change.

Also, there's a chance by the time we're ready for 5.0.0, this spec will be a W3C Recommendation. This issue is meant to track it so that we make a conscious decision before the 5.0.0 release.

Related: jquery/sizzle#237

Some of those selectors include:

  • case-insensitive attribute comparisons [attr="value" i] (Support case-insensitive attribute selectors [attr="value" i] #4841)
  • case-sensitive attribute comparisons [attr="value" s]
  • column combinator F || E
  • :not(selector1, selector2) - this one we may already fully support but it'd be good to verify
  • :has() - this one we may already fully support but it'd be good to verify
  • :is() - we'll probably need to implement it to support jQuery extensions inside
  • :where() - like :is() but doesn't contribute to specificity which shouldn't matter for us
  • :scope - since we use :scope ourselves to fix context, I'm not sure how feasible it is for us

For those we may just defer to the native engine and only add some tests:

  • :dir()
  • :lang(lang1, lang2, pattern)
  • :any-link
  • :local-link
  • :target-within
  • :focus-within
  • :focus-visible
  • :read-write
  • :read-only
  • :blank
  • :nth[-last]-child(An+B of selector)

There are many others but since we'd be deferring to the native engine where possible, maybe we don't need to test all of them.

The most important changes are those that may require updates to parsing, like F || E or [attr=value i].

Notes:

  • [attr=value s] is needed as some attribute comparisons should be case-insensitive by default; e.g. type in HTML documents. We should also check our behavior there.
  • :is() & :where() require forgiving parsing, we should also check that

Link to test case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant