Closed Bug 1789248 Opened 3 years ago Closed 3 years ago

Forgiving selectors should not be reported as supported with CSS.supports("selector(...)")

Categories

(Core :: DOM: CSS Object Model, task)

task

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: mgol, Assigned: emilio)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

CSS.supports() and @supports should return false for unrecognized selectors in per CSSWG resolution in https://github.com/w3c/csswg-drafts/issues/7280

This bug has been ported from a Chromium one: https://bugs.chromium.org/p/chromium/issues/detail?id=1359396

For why this matters for jQuery, see this comment:
https://github.com/w3c/csswg-drafts/issues/7676#issuecomment-1235714917
and that whole issue in general.

tl;dr is that jQuery has custom selector extensions but for performance reasons it first tries to run a provided selector through querySelectorAll and only when that fails it uses its own custom DOM traversal. However, this approach doesn't work for pseudo-classes using forgiving selector lists as parameters - like :has(). jQuery would like to migrate to testing the selector via CSS.supports("selector(...)") instead but right now it returns true for :has(:gibberish) as well. The linked CSS WG resolution makes the API return false in such cases, making it a viable tool for jQuery.

Summary: Forgiving selectors should not be reported as supported with CSS.supports() → Forgiving selectors should not be reported as supported with CSS.supports("selector(...)")
Blocks: 968240

Yes, I proposed that change in fact, I just didn't get to fix it just yet :)

Flags: needinfo?(emilio)
Assignee: nobody → emilio
Flags: needinfo?(emilio)

We've shipped it for a while.

Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3e0a5d1881e9 Disallow forgiving selector-parsing in @supports. r=firefox-style-system-reviewers,layout-reviewers,boris
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/35800 for changes under testing/web-platform/tests
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/07d280f89c51 Remove @supports selector pref. r=firefox-style-system-reviewers,layout-reviewers,boris
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
Upstream PR merged by moz-wptsync-bot
Regressions: 1790259
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: