- Notifications
You must be signed in to change notification settings - Fork20.6k
Commitd153c37
authored
Selector: Use jQuery
jQuery has followed the following logic for selector handling for ages:1. Modify the selector to adhere to scoping rules jQuery mandates.2. Try `qSA` on the modified selector. If it succeeds, use the results.3. If `qSA` threw an error, run the jQuery custom traversal instead.It worked fine so far but now CSS has a concept of forgiving selector lists thatsome selectors like `:is()` & `:has()` use. That means providing unrecognizedselectors as parameters to `:is()` & `:has()` no longer throws an error, it willjust return no results. That made browsers with native `:has()` support breakselectors using jQuery extensions inside, e.g. `:has(:contains("Item"))`.Detecting support for selectors can also be done via:```jsCSS.supports( "selector(SELECTOR_TO_BE_TESTED)" )```which returns a boolean. There was a recent spec change requiring this API toalways use non-forgiving parsing:w3c/csswg-drafts#7280 (comment)However, no browsers have implemented this change so far.To solve this, two changes are being made:1. In browsers supports the new spec change to `CSS.supports( "selector()" )`, use it before trying `qSA`.2. Otherwise, add `:has` to the buggy selectors list.Fixesgh-5098Closesgh-5107Refw3c/csswg-drafts#7676:has
ifCSS.supports(selector(...))
non-compliant1 parent78321f0 commitd153c37
File tree
5 files changed
+97
-17
lines changed- src
- selector
- test/unit
5 files changed
+97
-17
lines changedLines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
| 12 | + | |
12 | 13 |
| |
13 | 14 |
| |
14 | 15 |
| |
| |||
252 | 253 |
| |
253 | 254 |
| |
254 | 255 |
| |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
255 | 277 |
| |
256 | 278 |
| |
257 | 279 |
| |
|
Lines changed: 30 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
| 3 | + | |
3 | 4 |
| |
4 |
| - | |
| 5 | + | |
5 | 6 |
| |
6 |
| - | |
7 |
| - | |
8 |
| - | |
| 7 | + | |
| 8 | + | |
9 | 9 |
| |
10 |
| - | |
11 |
| - | |
12 |
| - | |
13 |
| - | |
14 |
| - | |
15 |
| - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
16 | 14 |
| |
17 |
| - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
18 | 37 |
| |
19 | 38 |
|
Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + |
Lines changed: 11 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
931 | 931 |
| |
932 | 932 |
| |
933 | 933 |
| |
934 |
| - | |
| 934 | + | |
935 | 935 |
| |
936 | 936 |
| |
937 | 937 |
| |
938 | 938 |
| |
939 | 939 |
| |
940 | 940 |
| |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
941 | 951 |
| |
942 | 952 |
| |
943 | 953 |
| |
|
Lines changed: 10 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
59 | 59 |
| |
60 | 60 |
| |
61 | 61 |
| |
62 |
| - | |
| 62 | + | |
| 63 | + | |
63 | 64 |
| |
64 | 65 |
| |
65 |
| - | |
| 66 | + | |
| 67 | + | |
66 | 68 |
| |
67 | 69 |
| |
68 |
| - | |
| 70 | + | |
| 71 | + | |
69 | 72 |
| |
70 | 73 |
| |
71 |
| - | |
| 74 | + | |
| 75 | + | |
72 | 76 |
| |
73 | 77 |
| |
74 |
| - | |
| 78 | + | |
| 79 | + | |
75 | 80 |
| |
76 | 81 |
| |
77 | 82 |
| |
|
0 commit comments
Comments
(0)