Skip to content

Commit cb21836

Browse files
committed
fixup! PR feedback
1 parent 7bdcbe1 commit cb21836

File tree

5 files changed

+190
-106
lines changed

5 files changed

+190
-106
lines changed

.github/workflows/browserstack-3.x.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
# Once a week every Tuesday
88
schedule:
9-
- cron: "42 1 * * 2"
9+
- cron: "12 2 * * 2"
1010

1111
jobs:
1212
test:

build/tasks/minify.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export async function minify( { dir, filename, version } ) {
4444
output: {
4545
ascii_only: true,
4646

47-
// Support: Android 4.0 only
48-
// UglifyJS 3 breaks Android 4.0 if this option is not enabled.
47+
// Support: Android 4.0 only, IE9 only
4948
// This is in lieu of setting ie for all of mangle, compress, and output
5049
ie8: true,
5150
preamble: banner

eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default [
8989
{
9090
files: [ "test/unit/**" ],
9191
languageOptions: {
92-
ecmaVersion: 2021,
92+
ecmaVersion: 2015,
9393
sourceType: "script",
9494
globals: {
9595
...globals.browser,
@@ -115,7 +115,7 @@ export default [
115115

116116
{
117117
files: [ "test/data/**" ],
118-
ignores: [ "test/data/jquery-2.2.3.js", "test/data/qunit-start.js" ],
118+
ignores: [ "test/data/jquery-*.js", "test/data/qunit-start.js" ],
119119
languageOptions: {
120120
ecmaVersion: 2015,
121121
sourceType: "script",

src/jquery/core.js

Lines changed: 184 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,87 @@ var findProp,
1111
class2type = {},
1212
oldInit = jQuery.fn.init,
1313
oldFind = jQuery.find,
14-
1514
rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
1615
rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
1716

1817
// Require that the "whitespace run" starts from a non-whitespace
1918
// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
2019
rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
2120

22-
migratePatchFunc( jQuery.fn, "init", function( arg1 ) {
23-
var args = Array.prototype.slice.call( arguments );
24-
25-
if ( jQuery.migrateIsPatchEnabled( "selector-empty-id" ) &&
26-
typeof arg1 === "string" && arg1 === "#" ) {
27-
28-
// JQuery( "#" ) is a bogus ID selector, but it returned an empty set
29-
// before jQuery 3.0
30-
migrateWarn( "selector-empty-id", "jQuery( '#' ) is not a valid selector" );
31-
args[ 0 ] = [];
32-
}
21+
migratePatchFunc(
22+
jQuery.fn,
23+
"init",
24+
function( arg1 ) {
25+
var args = Array.prototype.slice.call( arguments );
26+
27+
if (
28+
jQuery.migrateIsPatchEnabled( "selector-empty-id" ) &&
29+
typeof arg1 === "string" &&
30+
arg1 === "#"
31+
) {
32+
33+
// JQuery( "#" ) is a bogus ID selector, but it returned an empty set
34+
// before jQuery 3.0
35+
migrateWarn( "selector-empty-id", "jQuery( '#' ) is not a valid selector" );
36+
args[ 0 ] = [];
37+
}
3338

34-
return oldInit.apply( this, args );
35-
}, "selector-empty-id" );
39+
return oldInit.apply( this, args );
40+
},
41+
"selector-empty-id"
42+
);
3643

3744
// This is already done in Core but the above patch will lose this assignment
3845
// so we need to redo it. It doesn't matter whether the patch is enabled or not
3946
// as the method is always going to be a Migrate-created wrapper.
4047
jQuery.fn.init.prototype = jQuery.fn;
4148

42-
migratePatchFunc( jQuery, "find", function( selector ) {
43-
var args = Array.prototype.slice.call( arguments );
44-
45-
// Support: PhantomJS 1.x
46-
// String#match fails to match when used with a //g RegExp, only on some strings
47-
if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
49+
migratePatchFunc(
50+
jQuery,
51+
"find",
52+
function( selector ) {
53+
var args = Array.prototype.slice.call( arguments );
4854

49-
// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
50-
// First see if qS thinks it's a valid selector, if so avoid a false positive
51-
try {
52-
window.document.querySelector( selector );
53-
} catch ( err1 ) {
55+
// Support: PhantomJS 1.x
56+
// String#match fails to match when used with a //g RegExp, only on some strings
57+
if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
5458

55-
// Didn't *look* valid to qSA, warn and try quoting what we think is the value
56-
selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
57-
return "[" + attr + op + "\"" + value + "\"]";
58-
} );
59-
60-
// If the regexp *may* have created an invalid selector, don't update it
61-
// Note that there may be false alarms if selector uses jQuery extensions
59+
// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
60+
// First see if qS thinks it's a valid selector, if so avoid a false positive
6261
try {
6362
window.document.querySelector( selector );
64-
migrateWarn( "selector-hash",
65-
"Attribute selector with '#' must be quoted: " + args[ 0 ] );
66-
args[ 0 ] = selector;
67-
} catch ( err2 ) {
68-
migrateWarn( "selector-hash",
69-
"Attribute selector with '#' was not fixed: " + args[ 0 ] );
63+
} catch ( err1 ) {
64+
65+
// Didn't *look* valid to qSA, warn and try quoting what we think is the value
66+
selector = selector.replace(
67+
rattrHashGlob,
68+
function( _, attr, op, value ) {
69+
return "[" + attr + op + "\"" + value + "\"]";
70+
}
71+
);
72+
73+
// If the regexp *may* have created an invalid selector, don't update it
74+
// Note that there may be false alarms if selector uses jQuery extensions
75+
try {
76+
window.document.querySelector( selector );
77+
migrateWarn(
78+
"selector-hash",
79+
"Attribute selector with '#' must be quoted: " + args[ 0 ]
80+
);
81+
args[ 0 ] = selector;
82+
} catch ( err2 ) {
83+
migrateWarn(
84+
"selector-hash",
85+
"Attribute selector with '#' was not fixed: " + args[ 0 ]
86+
);
87+
}
7088
}
7189
}
72-
}
7390

74-
return oldFind.apply( this, args );
75-
}, "selector-hash" );
91+
return oldFind.apply( this, args );
92+
},
93+
"selector-hash"
94+
);
7695

7796
// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
7897
for ( findProp in oldFind ) {
@@ -82,97 +101,161 @@ for ( findProp in oldFind ) {
82101
}
83102

84103
// The number of elements contained in the matched element set
85-
migratePatchAndWarnFunc( jQuery.fn, "size", function() {
86-
return this.length;
87-
}, "size",
88-
"jQuery.fn.size() is deprecated and removed; use the .length property" );
89-
90-
migratePatchAndWarnFunc( jQuery, "parseJSON", function() {
91-
return JSON.parse.apply( null, arguments );
92-
}, "parseJSON",
93-
"jQuery.parseJSON is deprecated; use JSON.parse" );
94-
95-
migratePatchAndWarnFunc( jQuery, "holdReady", jQuery.holdReady,
96-
"holdReady", "jQuery.holdReady is deprecated" );
97-
98-
migratePatchAndWarnFunc( jQuery, "unique", jQuery.uniqueSort,
99-
"unique", "jQuery.unique is deprecated; use jQuery.uniqueSort" );
104+
migratePatchAndWarnFunc(
105+
jQuery.fn,
106+
"size",
107+
function() {
108+
return this.length;
109+
},
110+
"size",
111+
"jQuery.fn.size() is deprecated and removed; use the .length property"
112+
);
113+
114+
migratePatchAndWarnFunc(
115+
jQuery,
116+
"parseJSON",
117+
function() {
118+
return JSON.parse.apply( null, arguments );
119+
},
120+
"parseJSON",
121+
"jQuery.parseJSON is deprecated; use JSON.parse"
122+
);
123+
124+
migratePatchAndWarnFunc(
125+
jQuery,
126+
"holdReady",
127+
jQuery.holdReady,
128+
"holdReady",
129+
"jQuery.holdReady is deprecated"
130+
);
131+
132+
migratePatchAndWarnFunc(
133+
jQuery,
134+
"unique",
135+
jQuery.uniqueSort,
136+
"unique",
137+
"jQuery.unique is deprecated; use jQuery.uniqueSort"
138+
);
100139

101140
// Now jQuery.expr.pseudos is the standard incantation
102-
migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos, "expr-pre-pseudos",
103-
"jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" );
104-
migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos, "expr-pre-pseudos",
105-
"jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" );
141+
migrateWarnProp(
142+
jQuery.expr,
143+
"filters",
144+
jQuery.expr.pseudos,
145+
"expr-pre-pseudos",
146+
"jQuery.expr.filters is deprecated; use jQuery.expr.pseudos"
147+
);
148+
migrateWarnProp(
149+
jQuery.expr,
150+
":",
151+
jQuery.expr.pseudos,
152+
"expr-pre-pseudos",
153+
"jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos"
154+
);
106155

107156
// Prior to jQuery 3.1.1 there were internal refs so we don't warn there
108157
if ( jQueryVersionSince( "3.1.1" ) ) {
109-
migratePatchAndWarnFunc( jQuery, "trim", function( text ) {
110-
return text == null ?
111-
"" :
112-
( text + "" ).replace( rtrim, "$1" );
113-
}, "trim",
114-
"jQuery.trim is deprecated; use String.prototype.trim" );
158+
migratePatchAndWarnFunc(
159+
jQuery,
160+
"trim",
161+
function( text ) {
162+
return text == null ? "" : ( text + "" ).replace( rtrim, "$1" );
163+
},
164+
"trim",
165+
"jQuery.trim is deprecated; use String.prototype.trim"
166+
);
115167
}
116168

117169
// Prior to jQuery 3.2 there were internal refs so we don't warn there
118170
if ( jQueryVersionSince( "3.2.0" ) ) {
119-
migratePatchAndWarnFunc( jQuery, "nodeName", function( elem, name ) {
120-
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
121-
}, "nodeName",
122-
"jQuery.nodeName is deprecated" );
171+
migratePatchAndWarnFunc(
172+
jQuery,
173+
"nodeName",
174+
function( elem, name ) {
175+
return (
176+
elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase()
177+
);
178+
},
179+
"nodeName",
180+
"jQuery.nodeName is deprecated"
181+
);
123182

124-
migratePatchAndWarnFunc( jQuery, "isArray", Array.isArray, "isArray",
183+
migratePatchAndWarnFunc(
184+
jQuery,
185+
"isArray",
186+
Array.isArray,
187+
"isArray",
125188
"jQuery.isArray is deprecated; use Array.isArray"
126189
);
127190
}
128191

129192
if ( jQueryVersionSince( "3.3.0" ) ) {
193+
migratePatchAndWarnFunc(
194+
jQuery,
195+
"isNumeric",
196+
function( obj ) {
130197

131-
migratePatchAndWarnFunc( jQuery, "isNumeric", function( obj ) {
132-
133-
// As of jQuery 3.0, isNumeric is limited to
134-
// strings and numbers (primitives or objects)
135-
// that can be coerced to finite numbers (gh-2662)
136-
var type = typeof obj;
137-
return ( type === "number" || type === "string" ) &&
198+
// As of jQuery 3.0, isNumeric is limited to
199+
// strings and numbers (primitives or objects)
200+
// that can be coerced to finite numbers (gh-2662)
201+
var type = typeof obj;
202+
return (
203+
( type === "number" || type === "string" ) &&
138204

139205
// parseFloat NaNs numeric-cast false positives ("")
140206
// ...but misinterprets leading-number strings, e.g. hex literals ("0x...")
141207
// subtraction forces infinities to NaN
142-
!isNaN( obj - parseFloat( obj ) );
143-
}, "isNumeric",
144-
"jQuery.isNumeric() is deprecated"
208+
!isNaN( obj - parseFloat( obj ) )
209+
);
210+
},
211+
"isNumeric",
212+
"jQuery.isNumeric() is deprecated"
145213
);
146214

147215
// Populate the class2type map
148-
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".
149-
split( " " ),
150-
function( _, name ) {
151-
class2type[ "[object " + name + "]" ] = name.toLowerCase();
152-
} );
153-
154-
migratePatchAndWarnFunc( jQuery, "type", function( obj ) {
155-
if ( obj == null ) {
156-
return obj + "";
216+
jQuery.each(
217+
"Boolean Number String Function Array Date RegExp Object Error Symbol".split(
218+
" "
219+
),
220+
function( _, name ) {
221+
class2type[ "[object " + name + "]" ] = name.toLowerCase();
157222
}
223+
);
158224

159-
// Support: Android <=2.3 only (functionish RegExp)
160-
return typeof obj === "object" || typeof obj === "function" ?
161-
class2type[ Object.prototype.toString.call( obj ) ] || "object" :
162-
typeof obj;
163-
}, "type",
164-
"jQuery.type is deprecated" );
225+
migratePatchAndWarnFunc(
226+
jQuery,
227+
"type",
228+
function( obj ) {
229+
if ( obj == null ) {
230+
return obj + "";
231+
}
165232

166-
migratePatchAndWarnFunc( jQuery, "isFunction",
233+
// Support: Android <=2.3 only (functionish RegExp)
234+
return typeof obj === "object" || typeof obj === "function" ?
235+
class2type[ Object.prototype.toString.call( obj ) ] || "object" :
236+
typeof obj;
237+
},
238+
"type",
239+
"jQuery.type is deprecated"
240+
);
241+
242+
migratePatchAndWarnFunc(
243+
jQuery,
244+
"isFunction",
167245
function( obj ) {
168246
return typeof obj === "function";
169-
}, "isFunction",
170-
"jQuery.isFunction() is deprecated" );
247+
},
248+
"isFunction",
249+
"jQuery.isFunction() is deprecated"
250+
);
171251

172-
migratePatchAndWarnFunc( jQuery, "isWindow",
252+
migratePatchAndWarnFunc(
253+
jQuery,
254+
"isWindow",
173255
function( obj ) {
174256
return obj != null && obj === obj.window;
175-
}, "isWindow",
257+
},
258+
"isWindow",
176259
"jQuery.isWindow() is deprecated"
177260
);
178261
}

test/unit/jquery/effects.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ QUnit.test( "jQuery.easing", function( assert ) {
1010

1111
assert.expect( 4 );
1212

13+
// Keep the unused arguments.
14+
// The number is important for the test.
1315
jQuery.easing.testOld = function( _p, _n, _firstNum, _diff ) {
1416
assert.ok( false, "should not have been called" );
1517
};

0 commit comments

Comments
 (0)