aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/support.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 /test/unit/support.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 'test/unit/support.js')
-rw-r--r--test/unit/support.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/test/unit/support.js b/test/unit/support.js
index aa3386ef8..2bf43112f 100644
--- a/test/unit/support.js
+++ b/test/unit/support.js
@@ -59,31 +59,35 @@ testIframe(
userAgent = window.navigator.userAgent,
expectedMap = {
ie_11: {
- cssSupportsSelector: false,
+ cssHas: true,
reliableTrDimensions: false
},
chrome: {
- cssSupportsSelector: false,
+ cssHas: false,
reliableTrDimensions: true
},
safari: {
- cssSupportsSelector: false,
+ cssHas: false,
reliableTrDimensions: true
},
webkit: {
- cssSupportsSelector: true,
+ cssHas: true,
reliableTrDimensions: true
},
firefox_102: {
- cssSupportsSelector: false,
+ cssHas: true,
reliableTrDimensions: false
},
firefox: {
- cssSupportsSelector: true,
+ cssHas: true,
reliableTrDimensions: false
},
+ ios_14_15_3: {
+ cssHas: true,
+ reliableTrDimensions: true
+ },
ios: {
- cssSupportsSelector: false,
+ cssHas: false,
reliableTrDimensions: true
}
};
@@ -91,7 +95,7 @@ testIframe(
// Make the selector-native build pass tests.
for ( browserKey in expectedMap ) {
if ( !includesModule( "selector" ) ) {
- delete expectedMap[ browserKey ].cssSupportsSelector;
+ delete expectedMap[ browserKey ].cssHas;
}
}
@@ -105,6 +109,8 @@ testIframe(
expected = expectedMap.firefox_102;
} else if ( /firefox/i.test( userAgent ) ) {
expected = expectedMap.firefox;
+ } else if ( /iphone os (?:14_|15_[0123])/i.test( userAgent ) ) {
+ expected = expectedMap.ios_14_15_3;
} else if ( /(?:iphone|ipad);.*(?:iphone)? os \d+_/i.test( userAgent ) ) {
expected = expectedMap.ios;
} else if ( typeof URLSearchParams !== "undefined" &&