- Notifications
You must be signed in to change notification settings - Fork20.6k
Commit09d988b
authored
Selector: Make selector lists work with
jQuery 3.6.2 started using `CSS.supports( "selector(SELECTOR)" )` before using`querySelectorAll` on the selector. This was to solvegh-5098 - some selectors,like `:has()`, now had their parameters parsed in a forgiving way, meaningthat `:has(:fakepseudo)` no longer throws but just returns 0 results, breakingthat jQuery mechanism.A recent spec change made `CSS.supports( "selector(SELECTOR)" )` always usenon-forgiving parsing, allowing us to use this API for what we've used`try-catch` before.To solve the issue on the spec side for older jQuery versions, `:has()`parameters are no longer using forgiving parsing in the latest spec updatebut our new mechanism is more future-proof anyway.However, the jQuery implementation has a bug - in`CSS.supports( "selector(SELECTOR)" )`, `SELECTOR` needs to bea `<complex-selector>` and not a `<complex-selector-list>`. Which means thatselector lists now skip `qSA` and go to the jQuery custom traversal:```jsCSS.supports("selector(div:valid, span)"); // falseCSS.supports("selector(div:valid)"); // trueCSS.supports("selector(span)"); // true```To solve this, this commit wraps the selector list passed to`CSS.supports( "selector(:is(SELECTOR))" )` with `:is`, making it a singleselector again.See:*https://w3c.github.io/csswg-drafts/css-conditional-4/#at-supports-ext*https://w3c.github.io/csswg-drafts/selectors-4/#typedef-complex-selector*https://w3c.github.io/csswg-drafts/selectors-4/#typedef-complex-selector-listFixesgh-5177Closesgh-5178Refw3c/csswg-drafts#7280qSA
again1 parent024d871 commit09d988b
File tree
4 files changed
+34
-7
lines changed- src
- selector
- test/unit
4 files changed
+34
-7
lines changedLines changed: 8 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
255 | 255 |
| |
256 | 256 |
| |
257 | 257 |
| |
258 |
| - | |
259 |
| - | |
| 258 | + | |
| 259 | + | |
260 | 260 |
| |
261 | 261 |
| |
262 | 262 |
| |
263 | 263 |
| |
264 | 264 |
| |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
265 | 270 |
| |
266 |
| - | |
| 271 | + | |
267 | 272 |
| |
268 | 273 |
| |
269 | 274 |
| |
|
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
30 |
| - | |
31 |
| - | |
32 |
| - | |
| 30 | + | |
| 31 | + | |
33 | 32 |
| |
34 | 33 |
| |
35 | 34 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 |
| |
4 | 7 |
| |
5 | 8 |
| |
|
Lines changed: 21 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
400 | 400 |
| |
401 | 401 |
| |
402 | 402 |
| |
403 |
| - | |
| 403 | + | |
404 | 404 |
| |
405 | 405 |
| |
406 | 406 |
| |
407 | 407 |
| |
408 | 408 |
| |
409 | 409 |
| |
410 | 410 |
| |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
411 | 431 |
| |
412 | 432 |
| |
413 | 433 |
| |
|
0 commit comments
Comments
(0)