Skip to content

Commit 65e3545

Browse files
authored
Selector: Remove the workaround for :has; test both on iPhone & iPad
Remove the workaround for a broken `:has` selector; we no longer test on any browser with a buggy `:has`. Test on last three iOS versions on an iPhone, but on the last two iPadOS versions on an iPad. Also, fix test issues on an iPad. Closes gh-5714 Ref gh-5715
1 parent 98cc8c8 commit 65e3545

File tree

5 files changed

+32
-77
lines changed

5 files changed

+32
-77
lines changed

.github/workflows/browserstack.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ jobs:
3434
- 'Edge_latest-1'
3535
- 'Firefox_latest'
3636
- 'Firefox_latest-1'
37-
- '__iOS_26'
38-
- '__iOS_18'
39-
- '__iOS_17'
37+
- '_:iPhone 17_iOS_26'
38+
- '_:iPhone 16_iOS_18'
39+
- '_:iPhone 15 Pro_iOS_17'
40+
- '_:iPad Air 13 2025_iOS_26'
41+
- '_:iPad Air 13 2025_iOS_18'
4042
steps:
4143
- name: Checkout
4244
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

src/selector/rbuggyQSA.js

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
11
import { isIE } from "../var/isIE.js";
22
import { whitespace } from "../var/whitespace.js";
3-
import { support } from "./support.js";
43

5-
// Build QSA regex.
6-
// Regex strategy adopted from Diego Perini.
7-
export var rbuggyQSA = [];
4+
export var rbuggyQSA = isIE && new RegExp(
85

9-
if ( isIE ) {
10-
rbuggyQSA.push(
6+
// Support: IE 9 - 11+
7+
// IE's :disabled selector does not pick up the children of disabled fieldsets
8+
":enabled|:disabled|" +
119

12-
// Support: IE 9 - 11+
13-
// IE's :disabled selector does not pick up the children of disabled fieldsets
14-
":enabled",
15-
":disabled",
10+
// Support: IE 11+
11+
// IE 11 doesn't find elements on a `[name='']` query in some cases.
12+
// Adding a temporary attribute to the document before the selection works
13+
// around the issue.
14+
"\\[" + whitespace + "*name" + whitespace + "*=" +
15+
whitespace + "*(?:''|\"\")"
1616

17-
// Support: IE 11+
18-
// IE 11 doesn't find elements on a `[name='']` query in some cases.
19-
// Adding a temporary attribute to the document before the selection works
20-
// around the issue.
21-
"\\[" + whitespace + "*name" + whitespace + "*=" +
22-
whitespace + "*(?:''|\"\")"
23-
);
24-
}
25-
26-
if ( !support.cssHas ) {
27-
28-
// Our regular `try-catch` mechanism fails to detect natively-unsupported
29-
// pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`)
30-
// in browsers that parse the `:has()` argument as a forgiving selector list.
31-
// https://drafts.csswg.org/selectors/#relational now requires the argument
32-
// to be parsed unforgivingly, but browsers have not yet fully adjusted.
33-
rbuggyQSA.push( ":has" );
34-
}
35-
36-
rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
17+
);

src/selector/support.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

test/unit/event.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,10 +1438,17 @@ QUnit.test( "Submit event can be stopped (trac-11049)", function( assert ) {
14381438
form.remove();
14391439
} );
14401440

1441-
// Support: iOS <=7 - 18+
1441+
// Support: iOS <=7 - 26+
14421442
// iOS has the window.onbeforeunload field but doesn't support the beforeunload
14431443
// handler making it impossible to feature-detect the support.
1444-
QUnit[ /(ipad|iphone|ipod)/i.test( navigator.userAgent ) ? "skip" : "test" ](
1444+
QUnit[
1445+
/iphone os/i.test( navigator.userAgent ) || (
1446+
/\bversion\/\d+(?:\.\d+)+ safari/i.test( navigator.userAgent ) &&
1447+
navigator.maxTouchPoints > 1
1448+
) ?
1449+
"skip" :
1450+
"test"
1451+
](
14451452
"on(beforeunload)", function( assert ) {
14461453
assert.expect( 1 );
14471454
var iframe = jQuery( jQuery.parseHTML( "<iframe src='" + baseURL + "event/onbeforeunload.html'><iframe>" ) );

test/unit/support.js

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,48 +77,31 @@ testIframe(
7777
);
7878

7979
( function() {
80-
var expected, browserKey,
80+
var expected,
8181
userAgent = window.navigator.userAgent,
8282
expectedMap = {
8383
ie_11: {
84-
cssHas: true,
8584
reliableColDimensions: 11,
8685
reliableTrDimensions: false
8786
},
8887
chrome: {
89-
cssHas: true,
9088
reliableColDimensions: true,
9189
reliableTrDimensions: true
9290
},
9391
safari: {
94-
cssHas: true,
9592
reliableColDimensions: false,
9693
reliableTrDimensions: true
9794
},
9895
firefox: {
99-
cssHas: true,
10096
reliableColDimensions: false,
10197
reliableTrDimensions: false
10298
},
103-
ios_16_3: {
104-
cssHas: false,
105-
reliableColDimensions: false,
106-
reliableTrDimensions: true
107-
},
10899
ios: {
109-
cssHas: true,
110100
reliableColDimensions: false,
111101
reliableTrDimensions: true
112102
}
113103
};
114104

115-
// Make the selector-native build pass tests.
116-
for ( browserKey in expectedMap ) {
117-
if ( !includesModule( "selector" ) ) {
118-
delete expectedMap[ browserKey ].cssHas;
119-
}
120-
}
121-
122105
if ( QUnit.isIE ) {
123106
expected = expectedMap.ie_11;
124107
} else if ( /\b(?:headless)?chrome\//i.test( userAgent ) ) {
@@ -127,12 +110,14 @@ testIframe(
127110
expected = expectedMap.chrome;
128111
} else if ( /\bfirefox\//i.test( userAgent ) ) {
129112
expected = expectedMap.firefox;
130-
} else if ( /\biphone os 16_[0123]/i.test( userAgent ) ) {
131-
expected = expectedMap.ios_16_3;
132-
} else if ( /\b(?:iphone|ipad);.*(?:iphone)? os \d+_/i.test( userAgent ) ) {
113+
} else if ( /\biphone os \d+_/i.test( userAgent ) ) {
133114
expected = expectedMap.ios;
134115
} else if ( /\bversion\/\d+(?:\.\d+)+ safari/i.test( userAgent ) ) {
135-
expected = expectedMap.safari;
116+
if ( navigator.maxTouchPoints > 1 ) {
117+
expected = expectedMap.ios;
118+
} else {
119+
expected = expectedMap.safari;
120+
}
136121
}
137122

138123
QUnit.test( "Verify that support tests resolve as expected per browser", function( assert ) {

0 commit comments

Comments
 (0)