@@ -11,68 +11,87 @@ var findProp,
11
11
class2type = { } ,
12
12
oldInit = jQuery . fn . init ,
13
13
oldFind = jQuery . find ,
14
-
15
14
rattrHashTest = / \[ ( \s * [ - \w ] + \s * ) ( [ ~ | ^ $ * ] ? = ) \s * ( [ - \w # ] * ?# [ - \w # ] * ) \s * \] / ,
16
15
rattrHashGlob = / \[ ( \s * [ - \w ] + \s * ) ( [ ~ | ^ $ * ] ? = ) \s * ( [ - \w # ] * ?# [ - \w # ] * ) \s * \] / g,
17
16
18
17
// Require that the "whitespace run" starts from a non-whitespace
19
18
// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
20
19
rtrim = / ^ [ \s \uFEFF \xA0 ] + | ( [ ^ \s \uFEFF \xA0 ] ) [ \s \uFEFF \xA0 ] + $ / g;
21
20
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
+ }
33
38
34
- return oldInit . apply ( this , args ) ;
35
- } , "selector-empty-id" ) ;
39
+ return oldInit . apply ( this , args ) ;
40
+ } ,
41
+ "selector-empty-id"
42
+ ) ;
36
43
37
44
// This is already done in Core but the above patch will lose this assignment
38
45
// so we need to redo it. It doesn't matter whether the patch is enabled or not
39
46
// as the method is always going to be a Migrate-created wrapper.
40
47
jQuery . fn . init . prototype = jQuery . fn ;
41
48
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 ) ;
48
54
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 ) ) {
54
58
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
62
61
try {
63
62
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
+ }
70
88
}
71
89
}
72
- }
73
90
74
- return oldFind . apply ( this , args ) ;
75
- } , "selector-hash" ) ;
91
+ return oldFind . apply ( this , args ) ;
92
+ } ,
93
+ "selector-hash"
94
+ ) ;
76
95
77
96
// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
78
97
for ( findProp in oldFind ) {
@@ -82,97 +101,161 @@ for ( findProp in oldFind ) {
82
101
}
83
102
84
103
// 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
+ ) ;
100
139
101
140
// 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
+ ) ;
106
155
107
156
// Prior to jQuery 3.1.1 there were internal refs so we don't warn there
108
157
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
+ ) ;
115
167
}
116
168
117
169
// Prior to jQuery 3.2 there were internal refs so we don't warn there
118
170
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
+ ) ;
123
182
124
- migratePatchAndWarnFunc ( jQuery , "isArray" , Array . isArray , "isArray" ,
183
+ migratePatchAndWarnFunc (
184
+ jQuery ,
185
+ "isArray" ,
186
+ Array . isArray ,
187
+ "isArray" ,
125
188
"jQuery.isArray is deprecated; use Array.isArray"
126
189
) ;
127
190
}
128
191
129
192
if ( jQueryVersionSince ( "3.3.0" ) ) {
193
+ migratePatchAndWarnFunc (
194
+ jQuery ,
195
+ "isNumeric" ,
196
+ function ( obj ) {
130
197
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" ) &&
138
204
139
205
// parseFloat NaNs numeric-cast false positives ("")
140
206
// ...but misinterprets leading-number strings, e.g. hex literals ("0x...")
141
207
// 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"
145
213
) ;
146
214
147
215
// 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 ( ) ;
157
222
}
223
+ ) ;
158
224
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
+ }
165
232
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" ,
167
245
function ( obj ) {
168
246
return typeof obj === "function" ;
169
- } , "isFunction" ,
170
- "jQuery.isFunction() is deprecated" ) ;
247
+ } ,
248
+ "isFunction" ,
249
+ "jQuery.isFunction() is deprecated"
250
+ ) ;
171
251
172
- migratePatchAndWarnFunc ( jQuery , "isWindow" ,
252
+ migratePatchAndWarnFunc (
253
+ jQuery ,
254
+ "isWindow" ,
173
255
function ( obj ) {
174
256
return obj != null && obj === obj . window ;
175
- } , "isWindow" ,
257
+ } ,
258
+ "isWindow" ,
176
259
"jQuery.isWindow() is deprecated"
177
260
) ;
178
261
}
0 commit comments