46 |
46 |
47 function jQueryVersionSince( version ) { |
47 function jQueryVersionSince( version ) { |
48 return compareVersions( jQuery.fn.jquery, version ) >= 0; |
48 return compareVersions( jQuery.fn.jquery, version ) >= 0; |
49 } |
49 } |
50 |
50 |
|
51 // A map from disabled patch codes to `true`. This should really |
|
52 // be a `Set` but those are unsupported in IE. |
|
53 var disabledPatches = Object.create( null ); |
|
54 |
|
55 // Don't apply patches for specified codes. Helpful for code bases |
|
56 // where some Migrate warnings have been addressed and it's desirable |
|
57 // to avoid needless patches or false positives. |
|
58 jQuery.migrateDisablePatches = function() { |
|
59 var i; |
|
60 for ( i = 0; i < arguments.length; i++ ) { |
|
61 disabledPatches[ arguments[ i ] ] = true; |
|
62 } |
|
63 }; |
|
64 |
|
65 // Allow enabling patches disabled via `jQuery.migrateDisablePatches`. |
|
66 // Helpful if you want to disable a patch only for some code that won't |
|
67 // be updated soon to be able to focus on other warnings - and enable it |
|
68 // immediately after such a call: |
|
69 // ```js |
|
70 // jQuery.migrateDisablePatches( "workaroundA" ); |
|
71 // elem.pluginViolatingWarningA( "pluginMethod" ); |
|
72 // jQuery.migrateEnablePatches( "workaroundA" ); |
|
73 // ``` |
|
74 jQuery.migrateEnablePatches = function() { |
|
75 var i; |
|
76 for ( i = 0; i < arguments.length; i++ ) { |
|
77 delete disabledPatches[ arguments[ i ] ]; |
|
78 } |
|
79 }; |
|
80 |
|
81 jQuery.migrateIsPatchEnabled = function( patchCode ) { |
|
82 return !disabledPatches[ patchCode ]; |
|
83 }; |
|
84 |
51 ( function() { |
85 ( function() { |
52 |
86 |
53 // Support: IE9 only |
87 // Support: IE9 only |
54 // IE9 only creates console object when dev tools are first opened |
88 // IE9 only creates console object when dev tools are first opened |
55 // IE9 console is a host object, callable but doesn't have .apply() |
89 // IE9 console is a host object, callable but doesn't have .apply() |
56 if ( !window.console || !window.console.log ) { |
90 if ( !window.console || !window.console.log ) { |
57 return; |
91 return; |
58 } |
92 } |
59 |
93 |
60 // Need jQuery 3.0.0+ and no older Migrate loaded |
94 // Need jQuery 3.x-4.x and no older Migrate loaded |
61 if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) { |
95 if ( !jQuery || !jQueryVersionSince( "3.0.0" ) || |
62 window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" ); |
96 jQueryVersionSince( "5.0.0" ) ) { |
|
97 window.console.log( "JQMIGRATE: jQuery 3.x-4.x REQUIRED" ); |
63 } |
98 } |
64 if ( jQuery.migrateWarnings ) { |
99 if ( jQuery.migrateWarnings ) { |
65 window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" ); |
100 window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" ); |
66 } |
101 } |
67 |
102 |
89 jQuery.migrateReset = function() { |
124 jQuery.migrateReset = function() { |
90 warnedAbout = {}; |
125 warnedAbout = {}; |
91 jQuery.migrateWarnings.length = 0; |
126 jQuery.migrateWarnings.length = 0; |
92 }; |
127 }; |
93 |
128 |
94 function migrateWarn( msg ) { |
129 function migrateWarn( code, msg ) { |
95 var console = window.console; |
130 var console = window.console; |
96 if ( !jQuery.migrateDeduplicateWarnings || !warnedAbout[ msg ] ) { |
131 if ( jQuery.migrateIsPatchEnabled( code ) && |
|
132 ( !jQuery.migrateDeduplicateWarnings || !warnedAbout[ msg ] ) ) { |
97 warnedAbout[ msg ] = true; |
133 warnedAbout[ msg ] = true; |
98 jQuery.migrateWarnings.push( msg ); |
134 jQuery.migrateWarnings.push( msg + " [" + code + "]" ); |
99 if ( console && console.warn && !jQuery.migrateMute ) { |
135 if ( console && console.warn && !jQuery.migrateMute ) { |
100 console.warn( "JQMIGRATE: " + msg ); |
136 console.warn( "JQMIGRATE: " + msg ); |
101 if ( jQuery.migrateTrace && console.trace ) { |
137 if ( jQuery.migrateTrace && console.trace ) { |
102 console.trace(); |
138 console.trace(); |
103 } |
139 } |
104 } |
140 } |
105 } |
141 } |
106 } |
142 } |
107 |
143 |
108 function migrateWarnProp( obj, prop, value, msg ) { |
144 function migrateWarnProp( obj, prop, value, code, msg ) { |
109 Object.defineProperty( obj, prop, { |
145 Object.defineProperty( obj, prop, { |
110 configurable: true, |
146 configurable: true, |
111 enumerable: true, |
147 enumerable: true, |
112 get: function() { |
148 get: function() { |
113 migrateWarn( msg ); |
149 migrateWarn( code, msg ); |
114 return value; |
150 return value; |
115 }, |
151 }, |
116 set: function( newValue ) { |
152 set: function( newValue ) { |
117 migrateWarn( msg ); |
153 migrateWarn( code, msg ); |
118 value = newValue; |
154 value = newValue; |
119 } |
155 } |
120 } ); |
156 } ); |
121 } |
157 } |
122 |
158 |
123 function migrateWarnFunc( obj, prop, newFunc, msg ) { |
159 function migrateWarnFuncInternal( obj, prop, newFunc, code, msg ) { |
|
160 var finalFunc, |
|
161 origFunc = obj[ prop ]; |
|
162 |
124 obj[ prop ] = function() { |
163 obj[ prop ] = function() { |
125 migrateWarn( msg ); |
164 |
126 return newFunc.apply( this, arguments ); |
165 // If `msg` not provided, do not warn; more sophisticated warnings |
|
166 // logic is most likely embedded in `newFunc`, in that case here |
|
167 // we just care about the logic choosing the proper implementation |
|
168 // based on whether the patch is disabled or not. |
|
169 if ( msg ) { |
|
170 migrateWarn( code, msg ); |
|
171 } |
|
172 |
|
173 // Since patches can be disabled & enabled dynamically, we |
|
174 // need to decide which implementation to run on each invocation. |
|
175 finalFunc = jQuery.migrateIsPatchEnabled( code ) ? |
|
176 newFunc : |
|
177 |
|
178 // The function may not have existed originally so we need a fallback. |
|
179 ( origFunc || jQuery.noop ); |
|
180 |
|
181 return finalFunc.apply( this, arguments ); |
127 }; |
182 }; |
128 } |
183 } |
129 |
184 |
|
185 function migratePatchAndWarnFunc( obj, prop, newFunc, code, msg ) { |
|
186 if ( !msg ) { |
|
187 throw new Error( "No warning message provided" ); |
|
188 } |
|
189 return migrateWarnFuncInternal( obj, prop, newFunc, code, msg ); |
|
190 } |
|
191 |
|
192 function migratePatchFunc( obj, prop, newFunc, code ) { |
|
193 return migrateWarnFuncInternal( obj, prop, newFunc, code ); |
|
194 } |
|
195 |
130 if ( window.document.compatMode === "BackCompat" ) { |
196 if ( window.document.compatMode === "BackCompat" ) { |
131 |
197 |
132 // JQuery has never supported or tested Quirks Mode |
198 // jQuery has never supported or tested Quirks Mode |
133 migrateWarn( "jQuery is not compatible with Quirks Mode" ); |
199 migrateWarn( "quirks", "jQuery is not compatible with Quirks Mode" ); |
134 } |
200 } |
135 |
201 |
136 var findProp, |
202 var findProp, |
137 class2type = {}, |
203 class2type = {}, |
138 oldInit = jQuery.fn.init, |
204 oldInit = jQuery.fn.init, |
139 oldFind = jQuery.find, |
205 oldFind = jQuery.find, |
140 |
206 |
141 rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, |
207 rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, |
142 rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g, |
208 rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g, |
143 |
209 |
144 // Support: Android <=4.0 only |
210 // Require that the "whitespace run" starts from a non-whitespace |
145 // Make sure we trim BOM and NBSP |
211 // to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position. |
146 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; |
212 rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g; |
147 |
213 |
148 jQuery.fn.init = function( arg1 ) { |
214 migratePatchFunc( jQuery.fn, "init", function( arg1 ) { |
149 var args = Array.prototype.slice.call( arguments ); |
215 var args = Array.prototype.slice.call( arguments ); |
150 |
216 |
151 if ( typeof arg1 === "string" && arg1 === "#" ) { |
217 if ( jQuery.migrateIsPatchEnabled( "selector-empty-id" ) && |
152 |
218 typeof arg1 === "string" && arg1 === "#" ) { |
153 // JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0 |
219 |
154 migrateWarn( "jQuery( '#' ) is not a valid selector" ); |
220 // JQuery( "#" ) is a bogus ID selector, but it returned an empty set |
|
221 // before jQuery 3.0 |
|
222 migrateWarn( "selector-empty-id", "jQuery( '#' ) is not a valid selector" ); |
155 args[ 0 ] = []; |
223 args[ 0 ] = []; |
156 } |
224 } |
157 |
225 |
158 return oldInit.apply( this, args ); |
226 return oldInit.apply( this, args ); |
159 }; |
227 }, "selector-empty-id" ); |
|
228 |
|
229 // This is already done in Core but the above patch will lose this assignment |
|
230 // so we need to redo it. It doesn't matter whether the patch is enabled or not |
|
231 // as the method is always going to be a Migrate-created wrapper. |
160 jQuery.fn.init.prototype = jQuery.fn; |
232 jQuery.fn.init.prototype = jQuery.fn; |
161 |
233 |
162 jQuery.find = function( selector ) { |
234 migratePatchFunc( jQuery, "find", function( selector ) { |
163 var args = Array.prototype.slice.call( arguments ); |
235 var args = Array.prototype.slice.call( arguments ); |
164 |
236 |
165 // Support: PhantomJS 1.x |
237 // Support: PhantomJS 1.x |
166 // String#match fails to match when used with a //g RegExp, only on some strings |
238 // String#match fails to match when used with a //g RegExp, only on some strings |
167 if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { |
239 if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { |
179 |
251 |
180 // If the regexp *may* have created an invalid selector, don't update it |
252 // If the regexp *may* have created an invalid selector, don't update it |
181 // Note that there may be false alarms if selector uses jQuery extensions |
253 // Note that there may be false alarms if selector uses jQuery extensions |
182 try { |
254 try { |
183 window.document.querySelector( selector ); |
255 window.document.querySelector( selector ); |
184 migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] ); |
256 migrateWarn( "selector-hash", |
|
257 "Attribute selector with '#' must be quoted: " + args[ 0 ] ); |
185 args[ 0 ] = selector; |
258 args[ 0 ] = selector; |
186 } catch ( err2 ) { |
259 } catch ( err2 ) { |
187 migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] ); |
260 migrateWarn( "selector-hash", |
|
261 "Attribute selector with '#' was not fixed: " + args[ 0 ] ); |
188 } |
262 } |
189 } |
263 } |
190 } |
264 } |
191 |
265 |
192 return oldFind.apply( this, args ); |
266 return oldFind.apply( this, args ); |
193 }; |
267 }, "selector-hash" ); |
194 |
268 |
195 // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) |
269 // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) |
196 for ( findProp in oldFind ) { |
270 for ( findProp in oldFind ) { |
197 if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { |
271 if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { |
198 jQuery.find[ findProp ] = oldFind[ findProp ]; |
272 jQuery.find[ findProp ] = oldFind[ findProp ]; |
199 } |
273 } |
200 } |
274 } |
201 |
275 |
202 // The number of elements contained in the matched element set |
276 // The number of elements contained in the matched element set |
203 migrateWarnFunc( jQuery.fn, "size", function() { |
277 migratePatchAndWarnFunc( jQuery.fn, "size", function() { |
204 return this.length; |
278 return this.length; |
205 }, |
279 }, "size", |
206 "jQuery.fn.size() is deprecated and removed; use the .length property" ); |
280 "jQuery.fn.size() is deprecated and removed; use the .length property" ); |
207 |
281 |
208 migrateWarnFunc( jQuery, "parseJSON", function() { |
282 migratePatchAndWarnFunc( jQuery, "parseJSON", function() { |
209 return JSON.parse.apply( null, arguments ); |
283 return JSON.parse.apply( null, arguments ); |
210 }, |
284 }, "parseJSON", |
211 "jQuery.parseJSON is deprecated; use JSON.parse" ); |
285 "jQuery.parseJSON is deprecated; use JSON.parse" ); |
212 |
286 |
213 migrateWarnFunc( jQuery, "holdReady", jQuery.holdReady, |
287 migratePatchAndWarnFunc( jQuery, "holdReady", jQuery.holdReady, |
214 "jQuery.holdReady is deprecated" ); |
288 "holdReady", "jQuery.holdReady is deprecated" ); |
215 |
289 |
216 migrateWarnFunc( jQuery, "unique", jQuery.uniqueSort, |
290 migratePatchAndWarnFunc( jQuery, "unique", jQuery.uniqueSort, |
217 "jQuery.unique is deprecated; use jQuery.uniqueSort" ); |
291 "unique", "jQuery.unique is deprecated; use jQuery.uniqueSort" ); |
218 |
292 |
219 // Now jQuery.expr.pseudos is the standard incantation |
293 // Now jQuery.expr.pseudos is the standard incantation |
220 migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos, |
294 migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos, "expr-pre-pseudos", |
221 "jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" ); |
295 "jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" ); |
222 migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos, |
296 migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos, "expr-pre-pseudos", |
223 "jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" ); |
297 "jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" ); |
224 |
298 |
225 // Prior to jQuery 3.1.1 there were internal refs so we don't warn there |
299 // Prior to jQuery 3.1.1 there were internal refs so we don't warn there |
226 if ( jQueryVersionSince( "3.1.1" ) ) { |
300 if ( jQueryVersionSince( "3.1.1" ) ) { |
227 migrateWarnFunc( jQuery, "trim", function( text ) { |
301 migratePatchAndWarnFunc( jQuery, "trim", function( text ) { |
228 return text == null ? |
302 return text == null ? |
229 "" : |
303 "" : |
230 ( text + "" ).replace( rtrim, "" ); |
304 ( text + "" ).replace( rtrim, "$1" ); |
231 }, |
305 }, "trim", |
232 "jQuery.trim is deprecated; use String.prototype.trim" ); |
306 "jQuery.trim is deprecated; use String.prototype.trim" ); |
233 } |
307 } |
234 |
308 |
235 // Prior to jQuery 3.2 there were internal refs so we don't warn there |
309 // Prior to jQuery 3.2 there were internal refs so we don't warn there |
236 if ( jQueryVersionSince( "3.2.0" ) ) { |
310 if ( jQueryVersionSince( "3.2.0" ) ) { |
237 migrateWarnFunc( jQuery, "nodeName", function( elem, name ) { |
311 migratePatchAndWarnFunc( jQuery, "nodeName", function( elem, name ) { |
238 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
312 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
239 }, |
313 }, "nodeName", |
240 "jQuery.nodeName is deprecated" ); |
314 "jQuery.nodeName is deprecated" ); |
241 |
315 |
242 migrateWarnFunc( jQuery, "isArray", Array.isArray, |
316 migratePatchAndWarnFunc( jQuery, "isArray", Array.isArray, "isArray", |
243 "jQuery.isArray is deprecated; use Array.isArray" |
317 "jQuery.isArray is deprecated; use Array.isArray" |
244 ); |
318 ); |
245 } |
319 } |
246 |
320 |
247 if ( jQueryVersionSince( "3.3.0" ) ) { |
321 if ( jQueryVersionSince( "3.3.0" ) ) { |
248 |
322 |
249 migrateWarnFunc( jQuery, "isNumeric", function( obj ) { |
323 migratePatchAndWarnFunc( jQuery, "isNumeric", function( obj ) { |
250 |
324 |
251 // As of jQuery 3.0, isNumeric is limited to |
325 // As of jQuery 3.0, isNumeric is limited to |
252 // strings and numbers (primitives or objects) |
326 // strings and numbers (primitives or objects) |
253 // that can be coerced to finite numbers (gh-2662) |
327 // that can be coerced to finite numbers (gh-2662) |
254 var type = typeof obj; |
328 var type = typeof obj; |
256 |
330 |
257 // parseFloat NaNs numeric-cast false positives ("") |
331 // parseFloat NaNs numeric-cast false positives ("") |
258 // ...but misinterprets leading-number strings, e.g. hex literals ("0x...") |
332 // ...but misinterprets leading-number strings, e.g. hex literals ("0x...") |
259 // subtraction forces infinities to NaN |
333 // subtraction forces infinities to NaN |
260 !isNaN( obj - parseFloat( obj ) ); |
334 !isNaN( obj - parseFloat( obj ) ); |
261 }, |
335 }, "isNumeric", |
262 "jQuery.isNumeric() is deprecated" |
336 "jQuery.isNumeric() is deprecated" |
263 ); |
337 ); |
264 |
338 |
265 // Populate the class2type map |
339 // Populate the class2type map |
266 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol". |
340 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol". |
267 split( " " ), |
341 split( " " ), |
268 function( _, name ) { |
342 function( _, name ) { |
269 class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
343 class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
270 } ); |
344 } ); |
271 |
345 |
272 migrateWarnFunc( jQuery, "type", function( obj ) { |
346 migratePatchAndWarnFunc( jQuery, "type", function( obj ) { |
273 if ( obj == null ) { |
347 if ( obj == null ) { |
274 return obj + ""; |
348 return obj + ""; |
275 } |
349 } |
276 |
350 |
277 // Support: Android <=2.3 only (functionish RegExp) |
351 // Support: Android <=2.3 only (functionish RegExp) |
278 return typeof obj === "object" || typeof obj === "function" ? |
352 return typeof obj === "object" || typeof obj === "function" ? |
279 class2type[ Object.prototype.toString.call( obj ) ] || "object" : |
353 class2type[ Object.prototype.toString.call( obj ) ] || "object" : |
280 typeof obj; |
354 typeof obj; |
281 }, |
355 }, "type", |
282 "jQuery.type is deprecated" ); |
356 "jQuery.type is deprecated" ); |
283 |
357 |
284 migrateWarnFunc( jQuery, "isFunction", |
358 migratePatchAndWarnFunc( jQuery, "isFunction", |
285 function( obj ) { |
359 function( obj ) { |
286 return typeof obj === "function"; |
360 return typeof obj === "function"; |
287 }, |
361 }, "isFunction", |
288 "jQuery.isFunction() is deprecated" ); |
362 "jQuery.isFunction() is deprecated" ); |
289 |
363 |
290 migrateWarnFunc( jQuery, "isWindow", |
364 migratePatchAndWarnFunc( jQuery, "isWindow", |
291 function( obj ) { |
365 function( obj ) { |
292 return obj != null && obj === obj.window; |
366 return obj != null && obj === obj.window; |
293 }, |
367 }, "isWindow", |
294 "jQuery.isWindow() is deprecated" |
368 "jQuery.isWindow() is deprecated" |
295 ); |
369 ); |
296 } |
370 } |
297 |
371 |
298 // Support jQuery slim which excludes the ajax module |
372 // Support jQuery slim which excludes the ajax module |
299 if ( jQuery.ajax ) { |
373 if ( jQuery.ajax ) { |
300 |
374 |
301 var oldAjax = jQuery.ajax, |
375 var oldAjax = jQuery.ajax, |
302 rjsonp = /(=)\?(?=&|$)|\?\?/; |
376 rjsonp = /(=)\?(?=&|$)|\?\?/; |
303 |
377 |
304 jQuery.ajax = function( ) { |
378 migratePatchFunc( jQuery, "ajax", function() { |
305 var jQXHR = oldAjax.apply( this, arguments ); |
379 var jQXHR = oldAjax.apply( this, arguments ); |
306 |
380 |
307 // Be sure we got a jQXHR (e.g., not sync) |
381 // Be sure we got a jQXHR (e.g., not sync) |
308 if ( jQXHR.promise ) { |
382 if ( jQXHR.promise ) { |
309 migrateWarnFunc( jQXHR, "success", jQXHR.done, |
383 migratePatchAndWarnFunc( jQXHR, "success", jQXHR.done, "jqXHR-methods", |
310 "jQXHR.success is deprecated and removed" ); |
384 "jQXHR.success is deprecated and removed" ); |
311 migrateWarnFunc( jQXHR, "error", jQXHR.fail, |
385 migratePatchAndWarnFunc( jQXHR, "error", jQXHR.fail, "jqXHR-methods", |
312 "jQXHR.error is deprecated and removed" ); |
386 "jQXHR.error is deprecated and removed" ); |
313 migrateWarnFunc( jQXHR, "complete", jQXHR.always, |
387 migratePatchAndWarnFunc( jQXHR, "complete", jQXHR.always, "jqXHR-methods", |
314 "jQXHR.complete is deprecated and removed" ); |
388 "jQXHR.complete is deprecated and removed" ); |
315 } |
389 } |
316 |
390 |
317 return jQXHR; |
391 return jQXHR; |
318 }; |
392 }, "jqXHR-methods" ); |
319 |
393 |
320 // Only trigger the logic in jQuery <4 as the JSON-to-JSONP auto-promotion |
394 // Only trigger the logic in jQuery <4 as the JSON-to-JSONP auto-promotion |
321 // behavior is gone in jQuery 4.0 and as it has security implications, we don't |
395 // behavior is gone in jQuery 4.0 and as it has security implications, we don't |
322 // want to restore the legacy behavior. |
396 // want to restore the legacy behavior. |
323 if ( !jQueryVersionSince( "4.0.0" ) ) { |
397 if ( !jQueryVersionSince( "4.0.0" ) ) { |
332 typeof s.data === "string" && |
406 typeof s.data === "string" && |
333 ( s.contentType || "" ) |
407 ( s.contentType || "" ) |
334 .indexOf( "application/x-www-form-urlencoded" ) === 0 && |
408 .indexOf( "application/x-www-form-urlencoded" ) === 0 && |
335 rjsonp.test( s.data ) |
409 rjsonp.test( s.data ) |
336 ) ) { |
410 ) ) { |
337 migrateWarn( "JSON-to-JSONP auto-promotion is deprecated" ); |
411 migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated" ); |
338 } |
412 } |
339 } ); |
413 } ); |
340 } |
414 } |
341 |
415 |
342 } |
416 } |
343 |
417 |
344 var oldRemoveAttr = jQuery.fn.removeAttr, |
418 var oldRemoveAttr = jQuery.fn.removeAttr, |
345 oldToggleClass = jQuery.fn.toggleClass, |
419 oldToggleClass = jQuery.fn.toggleClass, |
346 rmatchNonSpace = /\S+/g; |
420 rmatchNonSpace = /\S+/g; |
347 |
421 |
348 jQuery.fn.removeAttr = function( name ) { |
422 migratePatchFunc( jQuery.fn, "removeAttr", function( name ) { |
349 var self = this; |
423 var self = this, |
|
424 patchNeeded = false; |
350 |
425 |
351 jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) { |
426 jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) { |
352 if ( jQuery.expr.match.bool.test( attr ) ) { |
427 if ( jQuery.expr.match.bool.test( attr ) ) { |
353 migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr ); |
428 |
|
429 // Only warn if at least a single node had the property set to |
|
430 // something else than `false`. Otherwise, this Migrate patch |
|
431 // doesn't influence the behavior and there's no need to set or warn. |
|
432 self.each( function() { |
|
433 if ( jQuery( this ).prop( attr ) !== false ) { |
|
434 patchNeeded = true; |
|
435 return false; |
|
436 } |
|
437 } ); |
|
438 } |
|
439 |
|
440 if ( patchNeeded ) { |
|
441 migrateWarn( "removeAttr-bool", |
|
442 "jQuery.fn.removeAttr no longer sets boolean properties: " + attr ); |
354 self.prop( attr, false ); |
443 self.prop( attr, false ); |
355 } |
444 } |
356 } ); |
445 } ); |
357 |
446 |
358 return oldRemoveAttr.apply( this, arguments ); |
447 return oldRemoveAttr.apply( this, arguments ); |
359 }; |
448 }, "removeAttr-bool" ); |
360 |
449 |
361 jQuery.fn.toggleClass = function( state ) { |
450 migratePatchFunc( jQuery.fn, "toggleClass", function( state ) { |
362 |
451 |
363 // Only deprecating no-args or single boolean arg |
452 // Only deprecating no-args or single boolean arg |
364 if ( state !== undefined && typeof state !== "boolean" ) { |
453 if ( state !== undefined && typeof state !== "boolean" ) { |
|
454 |
365 return oldToggleClass.apply( this, arguments ); |
455 return oldToggleClass.apply( this, arguments ); |
366 } |
456 } |
367 |
457 |
368 migrateWarn( "jQuery.fn.toggleClass( boolean ) is deprecated" ); |
458 migrateWarn( "toggleClass-bool", "jQuery.fn.toggleClass( boolean ) is deprecated" ); |
369 |
459 |
370 // Toggle entire class name of each element |
460 // Toggle entire class name of each element |
371 return this.each( function() { |
461 return this.each( function() { |
372 var className = this.getAttribute && this.getAttribute( "class" ) || ""; |
462 var className = this.getAttribute && this.getAttribute( "class" ) || ""; |
373 |
463 |
460 for ( name in options ) { |
550 for ( name in options ) { |
461 elem.style[ name ] = old[ name ]; |
551 elem.style[ name ] = old[ name ]; |
462 } |
552 } |
463 |
553 |
464 return ret; |
554 return ret; |
465 }; |
555 }, "swap" ); |
466 |
556 |
467 if ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) { |
557 if ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) { |
468 |
|
469 jQuery.cssProps = new Proxy( jQuery.cssProps || {}, { |
558 jQuery.cssProps = new Proxy( jQuery.cssProps || {}, { |
470 set: function() { |
559 set: function() { |
471 migrateWarn( "JQMIGRATE: jQuery.cssProps is deprecated" ); |
560 migrateWarn( "cssProps", "jQuery.cssProps is deprecated" ); |
472 return Reflect.set.apply( this, arguments ); |
561 return Reflect.set.apply( this, arguments ); |
473 } |
562 } |
474 } ); |
563 } ); |
475 } |
564 } |
476 |
565 |
477 // Create a dummy jQuery.cssNumber if missing. It won't be used by jQuery but |
566 // In jQuery >=4 where jQuery.cssNumber is missing fill it with the latest 3.x version: |
478 // it will prevent code adding new keys to it unconditionally from crashing. |
567 // https://github.com/jquery/jquery/blob/3.6.0/src/css.js#L212-L233 |
479 if ( !jQuery.cssNumber ) { |
568 // This way, number values for the CSS properties below won't start triggering |
480 jQuery.cssNumber = {}; |
569 // Migrate warnings when jQuery gets updated to >=4.0.0 (gh-438). |
|
570 if ( jQueryVersionSince( "4.0.0" ) ) { |
|
571 |
|
572 // We need to keep this as a local variable as we need it internally |
|
573 // in a `jQuery.fn.css` patch and this usage shouldn't warn. |
|
574 internalCssNumber = { |
|
575 animationIterationCount: true, |
|
576 columnCount: true, |
|
577 fillOpacity: true, |
|
578 flexGrow: true, |
|
579 flexShrink: true, |
|
580 fontWeight: true, |
|
581 gridArea: true, |
|
582 gridColumn: true, |
|
583 gridColumnEnd: true, |
|
584 gridColumnStart: true, |
|
585 gridRow: true, |
|
586 gridRowEnd: true, |
|
587 gridRowStart: true, |
|
588 lineHeight: true, |
|
589 opacity: true, |
|
590 order: true, |
|
591 orphans: true, |
|
592 widows: true, |
|
593 zIndex: true, |
|
594 zoom: true |
|
595 }; |
|
596 |
|
597 if ( typeof Proxy !== "undefined" ) { |
|
598 jQuery.cssNumber = new Proxy( internalCssNumber, { |
|
599 get: function() { |
|
600 migrateWarn( "css-number", "jQuery.cssNumber is deprecated" ); |
|
601 return Reflect.get.apply( this, arguments ); |
|
602 }, |
|
603 set: function() { |
|
604 migrateWarn( "css-number", "jQuery.cssNumber is deprecated" ); |
|
605 return Reflect.set.apply( this, arguments ); |
|
606 } |
|
607 } ); |
|
608 } else { |
|
609 |
|
610 // Support: IE 9-11+ |
|
611 // IE doesn't support proxies, but we still want to restore the legacy |
|
612 // jQuery.cssNumber there. |
|
613 jQuery.cssNumber = internalCssNumber; |
|
614 } |
|
615 } else { |
|
616 |
|
617 // Make `internalCssNumber` defined for jQuery <4 as well as it's needed |
|
618 // in the `jQuery.fn.css` patch below. |
|
619 internalCssNumber = jQuery.cssNumber; |
481 } |
620 } |
482 |
621 |
483 function isAutoPx( prop ) { |
622 function isAutoPx( prop ) { |
484 |
623 |
485 // The first test is used to ensure that: |
624 // The first test is used to ensure that: |
487 // 2. The prop is not empty. |
626 // 2. The prop is not empty. |
488 return ralphaStart.test( prop ) && |
627 return ralphaStart.test( prop ) && |
489 rautoPx.test( prop[ 0 ].toUpperCase() + prop.slice( 1 ) ); |
628 rautoPx.test( prop[ 0 ].toUpperCase() + prop.slice( 1 ) ); |
490 } |
629 } |
491 |
630 |
492 oldFnCss = jQuery.fn.css; |
631 origFnCss = jQuery.fn.css; |
493 |
632 |
494 jQuery.fn.css = function( name, value ) { |
633 migratePatchFunc( jQuery.fn, "css", function( name, value ) { |
495 var camelName, |
634 var camelName, |
496 origThis = this; |
635 origThis = this; |
|
636 |
497 if ( name && typeof name === "object" && !Array.isArray( name ) ) { |
637 if ( name && typeof name === "object" && !Array.isArray( name ) ) { |
498 jQuery.each( name, function( n, v ) { |
638 jQuery.each( name, function( n, v ) { |
499 jQuery.fn.css.call( origThis, n, v ); |
639 jQuery.fn.css.call( origThis, n, v ); |
500 } ); |
640 } ); |
501 return this; |
641 return this; |
502 } |
642 } |
|
643 |
503 if ( typeof value === "number" ) { |
644 if ( typeof value === "number" ) { |
504 camelName = camelCase( name ); |
645 camelName = camelCase( name ); |
505 if ( !isAutoPx( camelName ) && !jQuery.cssNumber[ camelName ] ) { |
646 |
506 migrateWarn( "Number-typed values are deprecated for jQuery.fn.css( \"" + |
647 // Use `internalCssNumber` to avoid triggering our warnings in this |
|
648 // internal check. |
|
649 if ( !isAutoPx( camelName ) && !internalCssNumber[ camelName ] ) { |
|
650 migrateWarn( "css-number", |
|
651 "Number-typed values are deprecated for jQuery.fn.css( \"" + |
507 name + "\", value )" ); |
652 name + "\", value )" ); |
508 } |
653 } |
509 } |
654 } |
510 |
655 |
511 return oldFnCss.apply( this, arguments ); |
656 return origFnCss.apply( this, arguments ); |
512 }; |
657 }, "css-number" ); |
513 |
658 |
514 var oldData = jQuery.data; |
659 var origData = jQuery.data; |
515 |
660 |
516 jQuery.data = function( elem, name, value ) { |
661 migratePatchFunc( jQuery, "data", function( elem, name, value ) { |
517 var curData, sameKeys, key; |
662 var curData, sameKeys, key; |
518 |
663 |
519 // Name can be an object, and each entry in the object is meant to be set as data |
664 // Name can be an object, and each entry in the object is meant to be set as data |
520 if ( name && typeof name === "object" && arguments.length === 2 ) { |
665 if ( name && typeof name === "object" && arguments.length === 2 ) { |
521 curData = jQuery.hasData( elem ) && oldData.call( this, elem ); |
666 |
|
667 curData = jQuery.hasData( elem ) && origData.call( this, elem ); |
522 sameKeys = {}; |
668 sameKeys = {}; |
523 for ( key in name ) { |
669 for ( key in name ) { |
524 if ( key !== camelCase( key ) ) { |
670 if ( key !== camelCase( key ) ) { |
525 migrateWarn( "jQuery.data() always sets/gets camelCased names: " + key ); |
671 migrateWarn( "data-camelCase", |
|
672 "jQuery.data() always sets/gets camelCased names: " + key ); |
526 curData[ key ] = name[ key ]; |
673 curData[ key ] = name[ key ]; |
527 } else { |
674 } else { |
528 sameKeys[ key ] = name[ key ]; |
675 sameKeys[ key ] = name[ key ]; |
529 } |
676 } |
530 } |
677 } |
531 |
678 |
532 oldData.call( this, elem, sameKeys ); |
679 origData.call( this, elem, sameKeys ); |
533 |
680 |
534 return name; |
681 return name; |
535 } |
682 } |
536 |
683 |
537 // If the name is transformed, look for the un-transformed name in the data object |
684 // If the name is transformed, look for the un-transformed name in the data object |
538 if ( name && typeof name === "string" && name !== camelCase( name ) ) { |
685 if ( name && typeof name === "string" && name !== camelCase( name ) ) { |
539 curData = jQuery.hasData( elem ) && oldData.call( this, elem ); |
686 |
|
687 curData = jQuery.hasData( elem ) && origData.call( this, elem ); |
540 if ( curData && name in curData ) { |
688 if ( curData && name in curData ) { |
541 migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name ); |
689 migrateWarn( "data-camelCase", |
|
690 "jQuery.data() always sets/gets camelCased names: " + name ); |
542 if ( arguments.length > 2 ) { |
691 if ( arguments.length > 2 ) { |
543 curData[ name ] = value; |
692 curData[ name ] = value; |
544 } |
693 } |
545 return curData[ name ]; |
694 return curData[ name ]; |
546 } |
695 } |
547 } |
696 } |
548 |
697 |
549 return oldData.apply( this, arguments ); |
698 return origData.apply( this, arguments ); |
550 }; |
699 }, "data-camelCase" ); |
551 |
700 |
552 // Support jQuery slim which excludes the effects module |
701 // Support jQuery slim which excludes the effects module |
553 if ( jQuery.fx ) { |
702 if ( jQuery.fx ) { |
554 |
703 |
555 var intervalValue, intervalMsg, |
704 var intervalValue, intervalMsg, |
556 oldTweenRun = jQuery.Tween.prototype.run, |
705 oldTweenRun = jQuery.Tween.prototype.run, |
557 linearEasing = function( pct ) { |
706 linearEasing = function( pct ) { |
558 return pct; |
707 return pct; |
559 }; |
708 }; |
560 |
709 |
561 jQuery.Tween.prototype.run = function( ) { |
710 migratePatchFunc( jQuery.Tween.prototype, "run", function( ) { |
562 if ( jQuery.easing[ this.easing ].length > 1 ) { |
711 if ( jQuery.easing[ this.easing ].length > 1 ) { |
563 migrateWarn( |
712 migrateWarn( |
|
713 "easing-one-arg", |
564 "'jQuery.easing." + this.easing.toString() + "' should use only one argument" |
714 "'jQuery.easing." + this.easing.toString() + "' should use only one argument" |
565 ); |
715 ); |
566 |
716 |
567 jQuery.easing[ this.easing ] = linearEasing; |
717 jQuery.easing[ this.easing ] = linearEasing; |
568 } |
718 } |
569 |
719 |
570 oldTweenRun.apply( this, arguments ); |
720 oldTweenRun.apply( this, arguments ); |
571 }; |
721 }, "easing-one-arg" ); |
572 |
722 |
573 intervalValue = jQuery.fx.interval || 13; |
723 intervalValue = jQuery.fx.interval; |
574 intervalMsg = "jQuery.fx.interval is deprecated"; |
724 intervalMsg = "jQuery.fx.interval is deprecated"; |
575 |
725 |
576 // Support: IE9, Android <=4.4 |
726 // Support: IE9, Android <=4.4 |
577 // Avoid false positives on browsers that lack rAF |
727 // Avoid false positives on browsers that lack rAF |
578 // Don't warn if document is hidden, jQuery uses setTimeout (#292) |
728 // Don't warn if document is hidden, jQuery uses setTimeout (#292) |
601 |
756 |
602 jQuery.event.props = []; |
757 jQuery.event.props = []; |
603 jQuery.event.fixHooks = {}; |
758 jQuery.event.fixHooks = {}; |
604 |
759 |
605 migrateWarnProp( jQuery.event.props, "concat", jQuery.event.props.concat, |
760 migrateWarnProp( jQuery.event.props, "concat", jQuery.event.props.concat, |
|
761 "event-old-patch", |
606 "jQuery.event.props.concat() is deprecated and removed" ); |
762 "jQuery.event.props.concat() is deprecated and removed" ); |
607 |
763 |
608 jQuery.event.fix = function( originalEvent ) { |
764 migratePatchFunc( jQuery.event, "fix", function( originalEvent ) { |
609 var event, |
765 var event, |
610 type = originalEvent.type, |
766 type = originalEvent.type, |
611 fixHook = this.fixHooks[ type ], |
767 fixHook = this.fixHooks[ type ], |
612 props = jQuery.event.props; |
768 props = jQuery.event.props; |
613 |
769 |
614 if ( props.length ) { |
770 if ( props.length ) { |
615 migrateWarn( "jQuery.event.props are deprecated and removed: " + props.join() ); |
771 migrateWarn( "event-old-patch", |
|
772 "jQuery.event.props are deprecated and removed: " + props.join() ); |
616 while ( props.length ) { |
773 while ( props.length ) { |
617 jQuery.event.addProp( props.pop() ); |
774 jQuery.event.addProp( props.pop() ); |
618 } |
775 } |
619 } |
776 } |
620 |
777 |
621 if ( fixHook && !fixHook._migrated_ ) { |
778 if ( fixHook && !fixHook._migrated_ ) { |
622 fixHook._migrated_ = true; |
779 fixHook._migrated_ = true; |
623 migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type ); |
780 migrateWarn( "event-old-patch", |
|
781 "jQuery.event.fixHooks are deprecated and removed: " + type ); |
624 if ( ( props = fixHook.props ) && props.length ) { |
782 if ( ( props = fixHook.props ) && props.length ) { |
625 while ( props.length ) { |
783 while ( props.length ) { |
626 jQuery.event.addProp( props.pop() ); |
784 jQuery.event.addProp( props.pop() ); |
627 } |
785 } |
628 } |
786 } |
629 } |
787 } |
630 |
788 |
631 event = originalFix.call( this, originalEvent ); |
789 event = originalFix.call( this, originalEvent ); |
632 |
790 |
633 return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event; |
791 return fixHook && fixHook.filter ? |
634 }; |
792 fixHook.filter( event, originalEvent ) : |
635 |
793 event; |
636 jQuery.event.add = function( elem, types ) { |
794 }, "event-old-patch" ); |
|
795 |
|
796 migratePatchFunc( jQuery.event, "add", function( elem, types ) { |
637 |
797 |
638 // This misses the multiple-types case but that seems awfully rare |
798 // This misses the multiple-types case but that seems awfully rare |
639 if ( elem === window && types === "load" && window.document.readyState === "complete" ) { |
799 if ( elem === window && types === "load" && window.document.readyState === "complete" ) { |
640 migrateWarn( "jQuery(window).on('load'...) called after load event occurred" ); |
800 migrateWarn( "load-after-event", |
|
801 "jQuery(window).on('load'...) called after load event occurred" ); |
641 } |
802 } |
642 return oldEventAdd.apply( this, arguments ); |
803 return oldEventAdd.apply( this, arguments ); |
643 }; |
804 }, "load-after-event" ); |
644 |
805 |
645 jQuery.each( [ "load", "unload", "error" ], function( _, name ) { |
806 jQuery.each( [ "load", "unload", "error" ], function( _, name ) { |
646 |
807 |
647 jQuery.fn[ name ] = function() { |
808 migratePatchFunc( jQuery.fn, name, function() { |
648 var args = Array.prototype.slice.call( arguments, 0 ); |
809 var args = Array.prototype.slice.call( arguments, 0 ); |
649 |
810 |
650 // If this is an ajax load() the first arg should be the string URL; |
811 // If this is an ajax load() the first arg should be the string URL; |
651 // technically this could also be the "Anything" arg of the event .load() |
812 // technically this could also be the "Anything" arg of the event .load() |
652 // which just goes to show why this dumb signature has been deprecated! |
813 // which just goes to show why this dumb signature has been deprecated! |
653 // jQuery custom builds that exclude the Ajax module justifiably die here. |
814 // jQuery custom builds that exclude the Ajax module justifiably die here. |
654 if ( name === "load" && typeof args[ 0 ] === "string" ) { |
815 if ( name === "load" && typeof args[ 0 ] === "string" ) { |
655 return oldLoad.apply( this, args ); |
816 return oldLoad.apply( this, args ); |
656 } |
817 } |
657 |
818 |
658 migrateWarn( "jQuery.fn." + name + "() is deprecated" ); |
819 migrateWarn( "shorthand-removed-v3", |
|
820 "jQuery.fn." + name + "() is deprecated" ); |
659 |
821 |
660 args.splice( 0, 0, name ); |
822 args.splice( 0, 0, name ); |
661 if ( arguments.length ) { |
823 if ( arguments.length ) { |
662 return this.on.apply( this, args ); |
824 return this.on.apply( this, args ); |
663 } |
825 } |
666 // - load and unload events don't need to bubble, only applied to window or image |
828 // - load and unload events don't need to bubble, only applied to window or image |
667 // - error event should not bubble to window, although it does pre-1.7 |
829 // - error event should not bubble to window, although it does pre-1.7 |
668 // See http://bugs.jquery.com/ticket/11820 |
830 // See http://bugs.jquery.com/ticket/11820 |
669 this.triggerHandler.apply( this, args ); |
831 this.triggerHandler.apply( this, args ); |
670 return this; |
832 return this; |
671 }; |
833 }, "shorthand-removed-v3" ); |
672 |
834 |
673 } ); |
835 } ); |
674 |
836 |
675 jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + |
837 jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + |
676 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
838 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
677 "change select submit keydown keypress keyup contextmenu" ).split( " " ), |
839 "change select submit keydown keypress keyup contextmenu" ).split( " " ), |
678 function( _i, name ) { |
840 function( _i, name ) { |
679 |
841 |
680 // Handle event binding |
842 // Handle event binding |
681 jQuery.fn[ name ] = function( data, fn ) { |
843 migratePatchAndWarnFunc( jQuery.fn, name, function( data, fn ) { |
682 migrateWarn( "jQuery.fn." + name + "() event shorthand is deprecated" ); |
|
683 return arguments.length > 0 ? |
844 return arguments.length > 0 ? |
684 this.on( name, null, data, fn ) : |
845 this.on( name, null, data, fn ) : |
685 this.trigger( name ); |
846 this.trigger( name ); |
686 }; |
847 }, |
|
848 "shorthand-deprecated-v3", |
|
849 "jQuery.fn." + name + "() event shorthand is deprecated" ); |
687 } ); |
850 } ); |
688 |
851 |
689 // Trigger "ready" event only once, on document ready |
852 // Trigger "ready" event only once, on document ready |
690 jQuery( function() { |
853 jQuery( function() { |
691 jQuery( window.document ).triggerHandler( "ready" ); |
854 jQuery( window.document ).triggerHandler( "ready" ); |
692 } ); |
855 } ); |
693 |
856 |
694 jQuery.event.special.ready = { |
857 jQuery.event.special.ready = { |
695 setup: function() { |
858 setup: function() { |
696 if ( this === window.document ) { |
859 if ( this === window.document ) { |
697 migrateWarn( "'ready' event is deprecated" ); |
860 migrateWarn( "ready-event", "'ready' event is deprecated" ); |
698 } |
861 } |
699 } |
862 } |
700 }; |
863 }; |
701 |
864 |
702 jQuery.fn.extend( { |
865 migratePatchAndWarnFunc( jQuery.fn, "bind", function( types, data, fn ) { |
703 |
866 return this.on( types, null, data, fn ); |
704 bind: function( types, data, fn ) { |
867 }, "pre-on-methods", "jQuery.fn.bind() is deprecated" ); |
705 migrateWarn( "jQuery.fn.bind() is deprecated" ); |
868 migratePatchAndWarnFunc( jQuery.fn, "unbind", function( types, fn ) { |
706 return this.on( types, null, data, fn ); |
869 return this.off( types, null, fn ); |
707 }, |
870 }, "pre-on-methods", "jQuery.fn.unbind() is deprecated" ); |
708 unbind: function( types, fn ) { |
871 migratePatchAndWarnFunc( jQuery.fn, "delegate", function( selector, types, data, fn ) { |
709 migrateWarn( "jQuery.fn.unbind() is deprecated" ); |
872 return this.on( types, selector, data, fn ); |
710 return this.off( types, null, fn ); |
873 }, "pre-on-methods", "jQuery.fn.delegate() is deprecated" ); |
711 }, |
874 migratePatchAndWarnFunc( jQuery.fn, "undelegate", function( selector, types, fn ) { |
712 delegate: function( selector, types, data, fn ) { |
875 return arguments.length === 1 ? |
713 migrateWarn( "jQuery.fn.delegate() is deprecated" ); |
876 this.off( selector, "**" ) : |
714 return this.on( types, selector, data, fn ); |
877 this.off( types, selector || "**", fn ); |
715 }, |
878 }, "pre-on-methods", "jQuery.fn.undelegate() is deprecated" ); |
716 undelegate: function( selector, types, fn ) { |
879 migratePatchAndWarnFunc( jQuery.fn, "hover", function( fnOver, fnOut ) { |
717 migrateWarn( "jQuery.fn.undelegate() is deprecated" ); |
880 return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver ); |
718 return arguments.length === 1 ? |
881 }, "pre-on-methods", "jQuery.fn.hover() is deprecated" ); |
719 this.off( selector, "**" ) : |
|
720 this.off( types, selector || "**", fn ); |
|
721 }, |
|
722 hover: function( fnOver, fnOut ) { |
|
723 migrateWarn( "jQuery.fn.hover() is deprecated" ); |
|
724 return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver ); |
|
725 } |
|
726 } ); |
|
727 |
882 |
728 var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, |
883 var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, |
729 origHtmlPrefilter = jQuery.htmlPrefilter, |
|
730 makeMarkup = function( html ) { |
884 makeMarkup = function( html ) { |
731 var doc = window.document.implementation.createHTMLDocument( "" ); |
885 var doc = window.document.implementation.createHTMLDocument( "" ); |
732 doc.body.innerHTML = html; |
886 doc.body.innerHTML = html; |
733 return doc.body && doc.body.innerHTML; |
887 return doc.body && doc.body.innerHTML; |
734 }, |
888 }, |
735 warnIfChanged = function( html ) { |
889 warnIfChanged = function( html ) { |
736 var changed = html.replace( rxhtmlTag, "<$1></$2>" ); |
890 var changed = html.replace( rxhtmlTag, "<$1></$2>" ); |
737 if ( changed !== html && makeMarkup( html ) !== makeMarkup( changed ) ) { |
891 if ( changed !== html && makeMarkup( html ) !== makeMarkup( changed ) ) { |
738 migrateWarn( "HTML tags must be properly nested and closed: " + html ); |
892 migrateWarn( "self-closed-tags", |
|
893 "HTML tags must be properly nested and closed: " + html ); |
739 } |
894 } |
740 }; |
895 }; |
741 |
896 |
|
897 /** |
|
898 * Deprecated, please use `jQuery.migrateDisablePatches( "self-closed-tags" )` instead. |
|
899 * @deprecated |
|
900 */ |
742 jQuery.UNSAFE_restoreLegacyHtmlPrefilter = function() { |
901 jQuery.UNSAFE_restoreLegacyHtmlPrefilter = function() { |
743 jQuery.htmlPrefilter = function( html ) { |
902 jQuery.migrateEnablePatches( "self-closed-tags" ); |
744 warnIfChanged( html ); |
|
745 return html.replace( rxhtmlTag, "<$1></$2>" ); |
|
746 }; |
|
747 }; |
903 }; |
748 |
904 |
749 jQuery.htmlPrefilter = function( html ) { |
905 migratePatchFunc( jQuery, "htmlPrefilter", function( html ) { |
750 warnIfChanged( html ); |
906 warnIfChanged( html ); |
751 return origHtmlPrefilter( html ); |
907 return html.replace( rxhtmlTag, "<$1></$2>" ); |
752 }; |
908 }, "self-closed-tags" ); |
753 |
909 |
754 var oldOffset = jQuery.fn.offset; |
910 // This patch needs to be disabled by default as it re-introduces |
755 |
911 // security issues (CVE-2020-11022, CVE-2020-11023). |
756 jQuery.fn.offset = function() { |
912 jQuery.migrateDisablePatches( "self-closed-tags" ); |
|
913 |
|
914 var origOffset = jQuery.fn.offset; |
|
915 |
|
916 migratePatchFunc( jQuery.fn, "offset", function() { |
757 var elem = this[ 0 ]; |
917 var elem = this[ 0 ]; |
758 |
918 |
759 if ( elem && ( !elem.nodeType || !elem.getBoundingClientRect ) ) { |
919 if ( elem && ( !elem.nodeType || !elem.getBoundingClientRect ) ) { |
760 migrateWarn( "jQuery.fn.offset() requires a valid DOM element" ); |
920 migrateWarn( "offset-valid-elem", "jQuery.fn.offset() requires a valid DOM element" ); |
761 return arguments.length ? this : undefined; |
921 return arguments.length ? this : undefined; |
762 } |
922 } |
763 |
923 |
764 return oldOffset.apply( this, arguments ); |
924 return origOffset.apply( this, arguments ); |
765 }; |
925 }, "offset-valid-elem" ); |
766 |
926 |
767 // Support jQuery slim which excludes the ajax module |
927 // Support jQuery slim which excludes the ajax module |
768 // The jQuery.param patch is about respecting `jQuery.ajaxSettings.traditional` |
928 // The jQuery.param patch is about respecting `jQuery.ajaxSettings.traditional` |
769 // so it doesn't make sense for the slim build. |
929 // so it doesn't make sense for the slim build. |
770 if ( jQuery.ajax ) { |
930 if ( jQuery.ajax ) { |
771 |
931 |
772 var oldParam = jQuery.param; |
932 var origParam = jQuery.param; |
773 |
933 |
774 jQuery.param = function( data, traditional ) { |
934 migratePatchFunc( jQuery, "param", function( data, traditional ) { |
775 var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
935 var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
776 |
936 |
777 if ( traditional === undefined && ajaxTraditional ) { |
937 if ( traditional === undefined && ajaxTraditional ) { |
778 |
938 |
779 migrateWarn( "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" ); |
939 migrateWarn( "param-ajax-traditional", |
|
940 "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" ); |
780 traditional = ajaxTraditional; |
941 traditional = ajaxTraditional; |
781 } |
942 } |
782 |
943 |
783 return oldParam.call( this, data, traditional ); |
944 return origParam.call( this, data, traditional ); |
784 }; |
945 }, "param-ajax-traditional" ); |
785 |
946 |
786 } |
947 } |
787 |
948 |
788 var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack; |
949 migratePatchAndWarnFunc( jQuery.fn, "andSelf", jQuery.fn.addBack, "andSelf", |
789 |
950 "jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()" ); |
790 jQuery.fn.andSelf = function() { |
|
791 migrateWarn( "jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()" ); |
|
792 return oldSelf.apply( this, arguments ); |
|
793 }; |
|
794 |
951 |
795 // Support jQuery slim which excludes the deferred module in jQuery 4.0+ |
952 // Support jQuery slim which excludes the deferred module in jQuery 4.0+ |
796 if ( jQuery.Deferred ) { |
953 if ( jQuery.Deferred ) { |
797 |
954 |
798 var oldDeferred = jQuery.Deferred, |
955 var oldDeferred = jQuery.Deferred, |