Skip to content

Support CSS Selectors Level 4 selectors #5111

@mgol

Description

@mgol

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions