aboutsummaryrefslogtreecommitdiffstats
path: root/src/selector.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-02-14 10:11:40 +0100
committerGitHub <noreply@github.com>2023-02-14 10:11:40 +0100
commit68aa2ef7571e2d9f91fad1aa9e5f956c04dc9ee9 (patch)
tree810ac3b135de06ac113921112f42396759e54147 /src/selector.js
parent2e644e845051703775b35b358eec5d3608a9465f (diff)
downloadjquery-68aa2ef7571e2d9f91fad1aa9e5f956c04dc9ee9.tar.gz
jquery-68aa2ef7571e2d9f91fad1aa9e5f956c04dc9ee9.zip
Selector: Stop relying on CSS.supports( "selector(...)" )
`CSS.supports( "selector(...)" )` has different semantics than selectors passed to `querySelectorAll`. Apart from the fact that the former returns `false` for unrecognized selectors and the latter throws, `qSA` is more forgiving and accepts some invalid selectors, auto-correcting them where needed - for example, mismatched brackers are auto-closed. This behavior difference is breaking for many users. To add to that, a recent CSSWG resolution made `:is()` & `:where()` the only pseudos with forgiving parsing; browsers are in the process of making `:has()` parsing unforgiving. Taking all that into account, we go back to our previous try-catch approach without relying on `CSS.supports( "selector(...)" )`. The only difference is we detect forgiving parsing in `:has()` and mark the selector as buggy. The PR also updates `playwright-webkit` so that we test against a version of WebKit that already has non-forgiving `:has()`. Fixes gh-5194 Closes gh-5206 Ref gh-5098 Ref gh-5107 Ref w3c/csswg-drafts#7676 Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
Diffstat (limited to 'src/selector.js')
-rw-r--r--src/selector.js27
1 files changed, 0 insertions, 27 deletions
diff --git a/src/selector.js b/src/selector.js
index 328eca45f..c995a65fe 100644
--- a/src/selector.js
+++ b/src/selector.js
@@ -22,7 +22,6 @@ import selectorError from "./selector/selectorError.js";
import unescapeSelector from "./selector/unescapeSelector.js";
import tokenize from "./selector/tokenize.js";
import toSelector from "./selector/toSelector.js";
-import support from "./selector/support.js";
// The following utils are attached directly to the jQuery object.
import "./selector/escapeSelector.js";
@@ -189,32 +188,6 @@ function find( selector, context, results, seed ) {
}
try {
-
- // `qSA` may not throw for unrecognized parts using forgiving parsing:
- // https://drafts.csswg.org/selectors/#forgiving-selector
- // like the `:is()` pseudo-class:
- // https://drafts.csswg.org/selectors/#matches
- // `CSS.supports` is still expected to return `false` then:
- // https://drafts.csswg.org/css-conditional-4/#typedef-supports-selector-fn
- // https://drafts.csswg.org/css-conditional-4/#dfn-support-selector
- if ( support.cssSupportsSelector &&
-
- // `CSS.supports( "selector(...)" )` requires the argument to the
- // `selector` function to be a `<complex-selector>`, not
- // a `<complex-selector-list>` which our selector may be. Wrapping with
- // `:is` works around the issue and is supported by all browsers
- // we support except for IE which will fail the support test anyway.
- // eslint-disable-next-line no-undef
- !CSS.supports( "selector(:is(" + newSelector + "))" ) ) {
-
- // Support: IE 11+
- // Throw to get to the same code path as an error directly in qSA.
- // Note: once we only support browser supporting
- // `CSS.supports('selector(...)')`, we can most likely drop
- // the `try-catch`. IE doesn't implement the API.
- throw new Error();
- }
-
push.apply( results,
newContext.querySelectorAll( newSelector )
);