1 /*! |
1 /*! |
2 * jQuery Migrate - v1.4.1 - 2016-05-19 |
2 * jQuery Migrate - v3.3.2 - 2020-11-18T08:29Z |
3 * Copyright jQuery Foundation and other contributors |
3 * Copyright OpenJS Foundation and other contributors |
4 */ |
4 */ |
5 (function( jQuery, window, undefined ) { |
5 ( function( factory ) { |
6 // See http://bugs.jquery.com/ticket/13335 |
6 "use strict"; |
7 // "use strict"; |
7 |
8 |
8 if ( typeof define === "function" && define.amd ) { |
9 |
9 |
10 jQuery.migrateVersion = "1.4.1"; |
10 // AMD. Register as an anonymous module. |
11 |
11 define( [ "jquery" ], function( jQuery ) { |
12 |
12 return factory( jQuery, window ); |
13 var warnedAbout = {}; |
13 } ); |
14 |
14 } else if ( typeof module === "object" && module.exports ) { |
15 // List of warnings already given; public read only |
15 |
16 jQuery.migrateWarnings = []; |
16 // Node/CommonJS |
17 |
17 // eslint-disable-next-line no-undef |
18 // Set to true to prevent console output; migrateWarnings still maintained |
18 module.exports = factory( require( "jquery" ), window ); |
19 // jQuery.migrateMute = false; |
19 } else { |
20 |
20 |
21 // Show a message on the console so devs know we're active |
21 // Browser globals |
22 if ( window.console && window.console.log ) { |
22 factory( jQuery, window ); |
|
23 } |
|
24 } )( function( jQuery, window ) { |
|
25 "use strict"; |
|
26 |
|
27 jQuery.migrateVersion = "3.3.2"; |
|
28 |
|
29 // Returns 0 if v1 == v2, -1 if v1 < v2, 1 if v1 > v2 |
|
30 function compareVersions( v1, v2 ) { |
|
31 var i, |
|
32 rVersionParts = /^(\d+)\.(\d+)\.(\d+)/, |
|
33 v1p = rVersionParts.exec( v1 ) || [ ], |
|
34 v2p = rVersionParts.exec( v2 ) || [ ]; |
|
35 |
|
36 for ( i = 1; i <= 3; i++ ) { |
|
37 if ( +v1p[ i ] > +v2p[ i ] ) { |
|
38 return 1; |
|
39 } |
|
40 if ( +v1p[ i ] < +v2p[ i ] ) { |
|
41 return -1; |
|
42 } |
|
43 } |
|
44 return 0; |
|
45 } |
|
46 |
|
47 function jQueryVersionSince( version ) { |
|
48 return compareVersions( jQuery.fn.jquery, version ) >= 0; |
|
49 } |
|
50 |
|
51 ( function() { |
|
52 |
|
53 // Support: IE9 only |
|
54 // IE9 only creates console object when dev tools are first opened |
|
55 // IE9 console is a host object, callable but doesn't have .apply() |
|
56 if ( !window.console || !window.console.log ) { |
|
57 return; |
|
58 } |
|
59 |
|
60 // Need jQuery 3.0.0+ and no older Migrate loaded |
|
61 if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) { |
|
62 window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" ); |
|
63 } |
|
64 if ( jQuery.migrateWarnings ) { |
|
65 window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" ); |
|
66 } |
|
67 |
|
68 // Show a message on the console so devs know we're active |
23 window.console.log( "JQMIGRATE: Migrate is installed" + |
69 window.console.log( "JQMIGRATE: Migrate is installed" + |
24 ( jQuery.migrateMute ? "" : " with logging active" ) + |
70 ( jQuery.migrateMute ? "" : " with logging active" ) + |
25 ", version " + jQuery.migrateVersion ); |
71 ", version " + jQuery.migrateVersion ); |
26 } |
72 |
|
73 } )(); |
|
74 |
|
75 var warnedAbout = {}; |
|
76 |
|
77 // By default each warning is only reported once. |
|
78 jQuery.migrateDeduplicateWarnings = true; |
|
79 |
|
80 // List of warnings already given; public read only |
|
81 jQuery.migrateWarnings = []; |
27 |
82 |
28 // Set to false to disable traces that appear with warnings |
83 // Set to false to disable traces that appear with warnings |
29 if ( jQuery.migrateTrace === undefined ) { |
84 if ( jQuery.migrateTrace === undefined ) { |
30 jQuery.migrateTrace = true; |
85 jQuery.migrateTrace = true; |
31 } |
86 } |
49 } |
104 } |
50 } |
105 } |
51 } |
106 } |
52 |
107 |
53 function migrateWarnProp( obj, prop, value, msg ) { |
108 function migrateWarnProp( obj, prop, value, msg ) { |
54 if ( Object.defineProperty ) { |
109 Object.defineProperty( obj, prop, { |
55 // On ES5 browsers (non-oldIE), warn if the code tries to get prop; |
110 configurable: true, |
56 // allow property to be overwritten in case some other plugin wants it |
111 enumerable: true, |
57 try { |
112 get: function() { |
58 Object.defineProperty( obj, prop, { |
113 migrateWarn( msg ); |
59 configurable: true, |
114 return value; |
60 enumerable: true, |
115 }, |
61 get: function() { |
116 set: function( newValue ) { |
62 migrateWarn( msg ); |
117 migrateWarn( msg ); |
63 return value; |
118 value = newValue; |
64 }, |
119 } |
65 set: function( newValue ) { |
120 } ); |
66 migrateWarn( msg ); |
121 } |
67 value = newValue; |
122 |
68 } |
123 function migrateWarnFunc( obj, prop, newFunc, msg ) { |
69 }); |
124 obj[ prop ] = function() { |
70 return; |
125 migrateWarn( msg ); |
71 } catch( err ) { |
126 return newFunc.apply( this, arguments ); |
72 // IE8 is a dope about Object.defineProperty, can't warn there |
127 }; |
73 } |
128 } |
74 } |
129 |
75 |
130 if ( window.document.compatMode === "BackCompat" ) { |
76 // Non-ES5 (or broken) browser; just set the property |
131 |
77 jQuery._definePropertyBroken = true; |
132 // JQuery has never supported or tested Quirks Mode |
78 obj[ prop ] = value; |
|
79 } |
|
80 |
|
81 if ( document.compatMode === "BackCompat" ) { |
|
82 // jQuery has never supported or tested Quirks Mode |
|
83 migrateWarn( "jQuery is not compatible with Quirks Mode" ); |
133 migrateWarn( "jQuery is not compatible with Quirks Mode" ); |
84 } |
134 } |
85 |
135 |
86 |
136 var findProp, |
87 var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn, |
137 class2type = {}, |
88 oldAttr = jQuery.attr, |
|
89 valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get || |
|
90 function() { return null; }, |
|
91 valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set || |
|
92 function() { return undefined; }, |
|
93 rnoType = /^(?:input|button)$/i, |
|
94 rnoAttrNodeType = /^[238]$/, |
|
95 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, |
|
96 ruseDefault = /^(?:checked|selected)$/i; |
|
97 |
|
98 // jQuery.attrFn |
|
99 migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" ); |
|
100 |
|
101 jQuery.attr = function( elem, name, value, pass ) { |
|
102 var lowerName = name.toLowerCase(), |
|
103 nType = elem && elem.nodeType; |
|
104 |
|
105 if ( pass ) { |
|
106 // Since pass is used internally, we only warn for new jQuery |
|
107 // versions where there isn't a pass arg in the formal params |
|
108 if ( oldAttr.length < 4 ) { |
|
109 migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); |
|
110 } |
|
111 if ( elem && !rnoAttrNodeType.test( nType ) && |
|
112 (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) { |
|
113 return jQuery( elem )[ name ]( value ); |
|
114 } |
|
115 } |
|
116 |
|
117 // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking |
|
118 // for disconnected elements we don't warn on $( "<button>", { type: "button" } ). |
|
119 if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) { |
|
120 migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8"); |
|
121 } |
|
122 |
|
123 // Restore boolHook for boolean property/attribute synchronization |
|
124 if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) { |
|
125 jQuery.attrHooks[ lowerName ] = { |
|
126 get: function( elem, name ) { |
|
127 // Align boolean attributes with corresponding properties |
|
128 // Fall back to attribute presence where some booleans are not supported |
|
129 var attrNode, |
|
130 property = jQuery.prop( elem, name ); |
|
131 return property === true || typeof property !== "boolean" && |
|
132 ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? |
|
133 |
|
134 name.toLowerCase() : |
|
135 undefined; |
|
136 }, |
|
137 set: function( elem, value, name ) { |
|
138 var propName; |
|
139 if ( value === false ) { |
|
140 // Remove boolean attributes when set to false |
|
141 jQuery.removeAttr( elem, name ); |
|
142 } else { |
|
143 // value is true since we know at this point it's type boolean and not false |
|
144 // Set boolean attributes to the same name and set the DOM property |
|
145 propName = jQuery.propFix[ name ] || name; |
|
146 if ( propName in elem ) { |
|
147 // Only set the IDL specifically if it already exists on the element |
|
148 elem[ propName ] = true; |
|
149 } |
|
150 |
|
151 elem.setAttribute( name, name.toLowerCase() ); |
|
152 } |
|
153 return name; |
|
154 } |
|
155 }; |
|
156 |
|
157 // Warn only for attributes that can remain distinct from their properties post-1.9 |
|
158 if ( ruseDefault.test( lowerName ) ) { |
|
159 migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" ); |
|
160 } |
|
161 } |
|
162 |
|
163 return oldAttr.call( jQuery, elem, name, value ); |
|
164 }; |
|
165 |
|
166 // attrHooks: value |
|
167 jQuery.attrHooks.value = { |
|
168 get: function( elem, name ) { |
|
169 var nodeName = ( elem.nodeName || "" ).toLowerCase(); |
|
170 if ( nodeName === "button" ) { |
|
171 return valueAttrGet.apply( this, arguments ); |
|
172 } |
|
173 if ( nodeName !== "input" && nodeName !== "option" ) { |
|
174 migrateWarn("jQuery.fn.attr('value') no longer gets properties"); |
|
175 } |
|
176 return name in elem ? |
|
177 elem.value : |
|
178 null; |
|
179 }, |
|
180 set: function( elem, value ) { |
|
181 var nodeName = ( elem.nodeName || "" ).toLowerCase(); |
|
182 if ( nodeName === "button" ) { |
|
183 return valueAttrSet.apply( this, arguments ); |
|
184 } |
|
185 if ( nodeName !== "input" && nodeName !== "option" ) { |
|
186 migrateWarn("jQuery.fn.attr('value', val) no longer sets properties"); |
|
187 } |
|
188 // Does not return so that setAttribute is also used |
|
189 elem.value = value; |
|
190 } |
|
191 }; |
|
192 |
|
193 |
|
194 var matched, browser, |
|
195 oldInit = jQuery.fn.init, |
138 oldInit = jQuery.fn.init, |
196 oldFind = jQuery.find, |
139 oldFind = jQuery.find, |
197 oldParseJSON = jQuery.parseJSON, |
140 |
198 rspaceAngle = /^\s*</, |
|
199 rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, |
141 rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, |
200 rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g, |
142 rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g, |
201 // Note: XSS check is done below after string is trimmed |
143 |
202 rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/; |
144 // Support: Android <=4.0 only |
203 |
145 // Make sure we trim BOM and NBSP |
204 // $(html) "looks like html" rule change |
146 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; |
205 jQuery.fn.init = function( selector, context, rootjQuery ) { |
147 |
206 var match, ret; |
148 jQuery.fn.init = function( arg1 ) { |
207 |
149 var args = Array.prototype.slice.call( arguments ); |
208 if ( selector && typeof selector === "string" ) { |
150 |
209 if ( !jQuery.isPlainObject( context ) && |
151 if ( typeof arg1 === "string" && arg1 === "#" ) { |
210 (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) { |
152 |
211 |
153 // JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0 |
212 // This is an HTML string according to the "old" rules; is it still? |
154 migrateWarn( "jQuery( '#' ) is not a valid selector" ); |
213 if ( !rspaceAngle.test( selector ) ) { |
155 args[ 0 ] = []; |
214 migrateWarn("$(html) HTML strings must start with '<' character"); |
156 } |
215 } |
157 |
216 if ( match[ 3 ] ) { |
158 return oldInit.apply( this, args ); |
217 migrateWarn("$(html) HTML text after last tag is ignored"); |
|
218 } |
|
219 |
|
220 // Consistently reject any HTML-like string starting with a hash (gh-9521) |
|
221 // Note that this may break jQuery 1.6.x code that otherwise would work. |
|
222 if ( match[ 0 ].charAt( 0 ) === "#" ) { |
|
223 migrateWarn("HTML string cannot start with a '#' character"); |
|
224 jQuery.error("JQMIGRATE: Invalid selector string (XSS)"); |
|
225 } |
|
226 |
|
227 // Now process using loose rules; let pre-1.8 play too |
|
228 // Is this a jQuery context? parseHTML expects a DOM element (#178) |
|
229 if ( context && context.context && context.context.nodeType ) { |
|
230 context = context.context; |
|
231 } |
|
232 |
|
233 if ( jQuery.parseHTML ) { |
|
234 return oldInit.call( this, |
|
235 jQuery.parseHTML( match[ 2 ], context && context.ownerDocument || |
|
236 context || document, true ), context, rootjQuery ); |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 ret = oldInit.apply( this, arguments ); |
|
242 |
|
243 // Fill in selector and context properties so .live() works |
|
244 if ( selector && selector.selector !== undefined ) { |
|
245 // A jQuery object, copy its properties |
|
246 ret.selector = selector.selector; |
|
247 ret.context = selector.context; |
|
248 |
|
249 } else { |
|
250 ret.selector = typeof selector === "string" ? selector : ""; |
|
251 if ( selector ) { |
|
252 ret.context = selector.nodeType? selector : context || document; |
|
253 } |
|
254 } |
|
255 |
|
256 return ret; |
|
257 }; |
159 }; |
258 jQuery.fn.init.prototype = jQuery.fn; |
160 jQuery.fn.init.prototype = jQuery.fn; |
259 |
161 |
260 jQuery.find = function( selector ) { |
162 jQuery.find = function( selector ) { |
261 var args = Array.prototype.slice.call( arguments ); |
163 var args = Array.prototype.slice.call( arguments ); |
289 |
191 |
290 return oldFind.apply( this, args ); |
192 return oldFind.apply( this, args ); |
291 }; |
193 }; |
292 |
194 |
293 // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) |
195 // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) |
294 var findProp; |
|
295 for ( findProp in oldFind ) { |
196 for ( findProp in oldFind ) { |
296 if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { |
197 if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { |
297 jQuery.find[ findProp ] = oldFind[ findProp ]; |
198 jQuery.find[ findProp ] = oldFind[ findProp ]; |
298 } |
199 } |
299 } |
200 } |
300 |
201 |
301 // Let $.parseJSON(falsy_value) return null |
|
302 jQuery.parseJSON = function( json ) { |
|
303 if ( !json ) { |
|
304 migrateWarn("jQuery.parseJSON requires a valid JSON string"); |
|
305 return null; |
|
306 } |
|
307 return oldParseJSON.apply( this, arguments ); |
|
308 }; |
|
309 |
|
310 jQuery.uaMatch = function( ua ) { |
|
311 ua = ua.toLowerCase(); |
|
312 |
|
313 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || |
|
314 /(webkit)[ \/]([\w.]+)/.exec( ua ) || |
|
315 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || |
|
316 /(msie) ([\w.]+)/.exec( ua ) || |
|
317 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || |
|
318 []; |
|
319 |
|
320 return { |
|
321 browser: match[ 1 ] || "", |
|
322 version: match[ 2 ] || "0" |
|
323 }; |
|
324 }; |
|
325 |
|
326 // Don't clobber any existing jQuery.browser in case it's different |
|
327 if ( !jQuery.browser ) { |
|
328 matched = jQuery.uaMatch( navigator.userAgent ); |
|
329 browser = {}; |
|
330 |
|
331 if ( matched.browser ) { |
|
332 browser[ matched.browser ] = true; |
|
333 browser.version = matched.version; |
|
334 } |
|
335 |
|
336 // Chrome is Webkit, but Webkit is also Safari. |
|
337 if ( browser.chrome ) { |
|
338 browser.webkit = true; |
|
339 } else if ( browser.webkit ) { |
|
340 browser.safari = true; |
|
341 } |
|
342 |
|
343 jQuery.browser = browser; |
|
344 } |
|
345 |
|
346 // Warn if the code tries to get jQuery.browser |
|
347 migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" ); |
|
348 |
|
349 // jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7 |
|
350 jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat"); |
|
351 migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" ); |
|
352 migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" ); |
|
353 |
|
354 jQuery.sub = function() { |
|
355 function jQuerySub( selector, context ) { |
|
356 return new jQuerySub.fn.init( selector, context ); |
|
357 } |
|
358 jQuery.extend( true, jQuerySub, this ); |
|
359 jQuerySub.superclass = this; |
|
360 jQuerySub.fn = jQuerySub.prototype = this(); |
|
361 jQuerySub.fn.constructor = jQuerySub; |
|
362 jQuerySub.sub = this.sub; |
|
363 jQuerySub.fn.init = function init( selector, context ) { |
|
364 var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub ); |
|
365 return instance instanceof jQuerySub ? |
|
366 instance : |
|
367 jQuerySub( instance ); |
|
368 }; |
|
369 jQuerySub.fn.init.prototype = jQuerySub.fn; |
|
370 var rootjQuerySub = jQuerySub(document); |
|
371 migrateWarn( "jQuery.sub() is deprecated" ); |
|
372 return jQuerySub; |
|
373 }; |
|
374 |
|
375 // The number of elements contained in the matched element set |
202 // The number of elements contained in the matched element set |
376 jQuery.fn.size = function() { |
203 migrateWarnFunc( jQuery.fn, "size", function() { |
377 migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" ); |
|
378 return this.length; |
204 return this.length; |
379 }; |
205 }, |
380 |
206 "jQuery.fn.size() is deprecated and removed; use the .length property" ); |
381 |
207 |
382 var internalSwapCall = false; |
208 migrateWarnFunc( jQuery, "parseJSON", function() { |
|
209 return JSON.parse.apply( null, arguments ); |
|
210 }, |
|
211 "jQuery.parseJSON is deprecated; use JSON.parse" ); |
|
212 |
|
213 migrateWarnFunc( jQuery, "holdReady", jQuery.holdReady, |
|
214 "jQuery.holdReady is deprecated" ); |
|
215 |
|
216 migrateWarnFunc( jQuery, "unique", jQuery.uniqueSort, |
|
217 "jQuery.unique is deprecated; use jQuery.uniqueSort" ); |
|
218 |
|
219 // Now jQuery.expr.pseudos is the standard incantation |
|
220 migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos, |
|
221 "jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" ); |
|
222 migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos, |
|
223 "jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" ); |
|
224 |
|
225 // Prior to jQuery 3.1.1 there were internal refs so we don't warn there |
|
226 if ( jQueryVersionSince( "3.1.1" ) ) { |
|
227 migrateWarnFunc( jQuery, "trim", function( text ) { |
|
228 return text == null ? |
|
229 "" : |
|
230 ( text + "" ).replace( rtrim, "" ); |
|
231 }, |
|
232 "jQuery.trim is deprecated; use String.prototype.trim" ); |
|
233 } |
|
234 |
|
235 // Prior to jQuery 3.2 there were internal refs so we don't warn there |
|
236 if ( jQueryVersionSince( "3.2.0" ) ) { |
|
237 migrateWarnFunc( jQuery, "nodeName", function( elem, name ) { |
|
238 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
|
239 }, |
|
240 "jQuery.nodeName is deprecated" ); |
|
241 |
|
242 migrateWarnFunc( jQuery, "isArray", Array.isArray, |
|
243 "jQuery.isArray is deprecated; use Array.isArray" |
|
244 ); |
|
245 } |
|
246 |
|
247 if ( jQueryVersionSince( "3.3.0" ) ) { |
|
248 |
|
249 migrateWarnFunc( jQuery, "isNumeric", function( obj ) { |
|
250 |
|
251 // As of jQuery 3.0, isNumeric is limited to |
|
252 // strings and numbers (primitives or objects) |
|
253 // that can be coerced to finite numbers (gh-2662) |
|
254 var type = typeof obj; |
|
255 return ( type === "number" || type === "string" ) && |
|
256 |
|
257 // parseFloat NaNs numeric-cast false positives ("") |
|
258 // ...but misinterprets leading-number strings, e.g. hex literals ("0x...") |
|
259 // subtraction forces infinities to NaN |
|
260 !isNaN( obj - parseFloat( obj ) ); |
|
261 }, |
|
262 "jQuery.isNumeric() is deprecated" |
|
263 ); |
|
264 |
|
265 // Populate the class2type map |
|
266 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol". |
|
267 split( " " ), |
|
268 function( _, name ) { |
|
269 class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
|
270 } ); |
|
271 |
|
272 migrateWarnFunc( jQuery, "type", function( obj ) { |
|
273 if ( obj == null ) { |
|
274 return obj + ""; |
|
275 } |
|
276 |
|
277 // Support: Android <=2.3 only (functionish RegExp) |
|
278 return typeof obj === "object" || typeof obj === "function" ? |
|
279 class2type[ Object.prototype.toString.call( obj ) ] || "object" : |
|
280 typeof obj; |
|
281 }, |
|
282 "jQuery.type is deprecated" ); |
|
283 |
|
284 migrateWarnFunc( jQuery, "isFunction", |
|
285 function( obj ) { |
|
286 return typeof obj === "function"; |
|
287 }, |
|
288 "jQuery.isFunction() is deprecated" ); |
|
289 |
|
290 migrateWarnFunc( jQuery, "isWindow", |
|
291 function( obj ) { |
|
292 return obj != null && obj === obj.window; |
|
293 }, |
|
294 "jQuery.isWindow() is deprecated" |
|
295 ); |
|
296 } |
|
297 |
|
298 // Support jQuery slim which excludes the ajax module |
|
299 if ( jQuery.ajax ) { |
|
300 |
|
301 var oldAjax = jQuery.ajax, |
|
302 rjsonp = /(=)\?(?=&|$)|\?\?/; |
|
303 |
|
304 jQuery.ajax = function( ) { |
|
305 var jQXHR = oldAjax.apply( this, arguments ); |
|
306 |
|
307 // Be sure we got a jQXHR (e.g., not sync) |
|
308 if ( jQXHR.promise ) { |
|
309 migrateWarnFunc( jQXHR, "success", jQXHR.done, |
|
310 "jQXHR.success is deprecated and removed" ); |
|
311 migrateWarnFunc( jQXHR, "error", jQXHR.fail, |
|
312 "jQXHR.error is deprecated and removed" ); |
|
313 migrateWarnFunc( jQXHR, "complete", jQXHR.always, |
|
314 "jQXHR.complete is deprecated and removed" ); |
|
315 } |
|
316 |
|
317 return jQXHR; |
|
318 }; |
|
319 |
|
320 // 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 |
|
322 // want to restore the legacy behavior. |
|
323 if ( !jQueryVersionSince( "4.0.0" ) ) { |
|
324 |
|
325 // Register this prefilter before the jQuery one. Otherwise, a promoted |
|
326 // request is transformed into one with the script dataType and we can't |
|
327 // catch it anymore. |
|
328 jQuery.ajaxPrefilter( "+json", function( s ) { |
|
329 |
|
330 // Warn if JSON-to-JSONP auto-promotion happens. |
|
331 if ( s.jsonp !== false && ( rjsonp.test( s.url ) || |
|
332 typeof s.data === "string" && |
|
333 ( s.contentType || "" ) |
|
334 .indexOf( "application/x-www-form-urlencoded" ) === 0 && |
|
335 rjsonp.test( s.data ) |
|
336 ) ) { |
|
337 migrateWarn( "JSON-to-JSONP auto-promotion is deprecated" ); |
|
338 } |
|
339 } ); |
|
340 } |
|
341 |
|
342 } |
|
343 |
|
344 var oldRemoveAttr = jQuery.fn.removeAttr, |
|
345 oldToggleClass = jQuery.fn.toggleClass, |
|
346 rmatchNonSpace = /\S+/g; |
|
347 |
|
348 jQuery.fn.removeAttr = function( name ) { |
|
349 var self = this; |
|
350 |
|
351 jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) { |
|
352 if ( jQuery.expr.match.bool.test( attr ) ) { |
|
353 migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr ); |
|
354 self.prop( attr, false ); |
|
355 } |
|
356 } ); |
|
357 |
|
358 return oldRemoveAttr.apply( this, arguments ); |
|
359 }; |
|
360 |
|
361 jQuery.fn.toggleClass = function( state ) { |
|
362 |
|
363 // Only deprecating no-args or single boolean arg |
|
364 if ( state !== undefined && typeof state !== "boolean" ) { |
|
365 return oldToggleClass.apply( this, arguments ); |
|
366 } |
|
367 |
|
368 migrateWarn( "jQuery.fn.toggleClass( boolean ) is deprecated" ); |
|
369 |
|
370 // Toggle entire class name of each element |
|
371 return this.each( function() { |
|
372 var className = this.getAttribute && this.getAttribute( "class" ) || ""; |
|
373 |
|
374 if ( className ) { |
|
375 jQuery.data( this, "__className__", className ); |
|
376 } |
|
377 |
|
378 // If the element has a class name or if we're passed `false`, |
|
379 // then remove the whole classname (if there was one, the above saved it). |
|
380 // Otherwise bring back whatever was previously saved (if anything), |
|
381 // falling back to the empty string if nothing was stored. |
|
382 if ( this.setAttribute ) { |
|
383 this.setAttribute( "class", |
|
384 className || state === false ? |
|
385 "" : |
|
386 jQuery.data( this, "__className__" ) || "" |
|
387 ); |
|
388 } |
|
389 } ); |
|
390 }; |
|
391 |
|
392 function camelCase( string ) { |
|
393 return string.replace( /-([a-z])/g, function( _, letter ) { |
|
394 return letter.toUpperCase(); |
|
395 } ); |
|
396 } |
|
397 |
|
398 var oldFnCss, |
|
399 internalSwapCall = false, |
|
400 ralphaStart = /^[a-z]/, |
|
401 |
|
402 // The regex visualized: |
|
403 // |
|
404 // /----------\ |
|
405 // | | /-------\ |
|
406 // | / Top \ | | | |
|
407 // /--- Border ---+-| Right |-+---+- Width -+---\ |
|
408 // | | Bottom | | |
|
409 // | \ Left / | |
|
410 // | | |
|
411 // | /----------\ | |
|
412 // | /-------------\ | | |- END |
|
413 // | | | | / Top \ | | |
|
414 // | | / Margin \ | | | Right | | | |
|
415 // |---------+-| |-+---+-| Bottom |-+----| |
|
416 // | \ Padding / \ Left / | |
|
417 // BEGIN -| | |
|
418 // | /---------\ | |
|
419 // | | | | |
|
420 // | | / Min \ | / Width \ | |
|
421 // \--------------+-| |-+---| |---/ |
|
422 // \ Max / \ Height / |
|
423 rautoPx = /^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/; |
383 |
424 |
384 // If this version of jQuery has .swap(), don't false-alarm on internal uses |
425 // If this version of jQuery has .swap(), don't false-alarm on internal uses |
385 if ( jQuery.swap ) { |
426 if ( jQuery.swap ) { |
386 jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) { |
427 jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) { |
387 var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get; |
428 var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get; |
421 } |
462 } |
422 |
463 |
423 return ret; |
464 return ret; |
424 }; |
465 }; |
425 |
466 |
426 |
467 if ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) { |
427 // Ensure that $.ajax gets the new parseJSON defined in core.js |
468 |
428 jQuery.ajaxSetup({ |
469 jQuery.cssProps = new Proxy( jQuery.cssProps || {}, { |
429 converters: { |
470 set: function() { |
430 "text json": jQuery.parseJSON |
471 migrateWarn( "JQMIGRATE: jQuery.cssProps is deprecated" ); |
431 } |
472 return Reflect.set.apply( this, arguments ); |
432 }); |
473 } |
433 |
474 } ); |
434 |
475 } |
435 var oldFnData = jQuery.fn.data; |
476 |
436 |
477 // Create a dummy jQuery.cssNumber if missing. It won't be used by jQuery but |
437 jQuery.fn.data = function( name ) { |
478 // it will prevent code adding new keys to it unconditionally from crashing. |
438 var ret, evt, |
479 if ( !jQuery.cssNumber ) { |
439 elem = this[0]; |
480 jQuery.cssNumber = {}; |
440 |
481 } |
441 // Handles 1.7 which has this behavior and 1.8 which doesn't |
482 |
442 if ( elem && name === "events" && arguments.length === 1 ) { |
483 function isAutoPx( prop ) { |
443 ret = jQuery.data( elem, name ); |
484 |
444 evt = jQuery._data( elem, name ); |
485 // The first test is used to ensure that: |
445 if ( ( ret === undefined || ret === evt ) && evt !== undefined ) { |
486 // 1. The prop starts with a lowercase letter (as we uppercase it for the second regex). |
446 migrateWarn("Use of jQuery.fn.data('events') is deprecated"); |
487 // 2. The prop is not empty. |
447 return evt; |
488 return ralphaStart.test( prop ) && |
448 } |
489 rautoPx.test( prop[ 0 ].toUpperCase() + prop.slice( 1 ) ); |
449 } |
490 } |
450 return oldFnData.apply( this, arguments ); |
491 |
451 }; |
492 oldFnCss = jQuery.fn.css; |
452 |
493 |
453 |
494 jQuery.fn.css = function( name, value ) { |
454 var rscriptType = /\/(java|ecma)script/i; |
495 var camelName, |
455 |
496 origThis = this; |
456 // Since jQuery.clean is used internally on older versions, we only shim if it's missing |
497 if ( name && typeof name === "object" && !Array.isArray( name ) ) { |
457 if ( !jQuery.clean ) { |
498 jQuery.each( name, function( n, v ) { |
458 jQuery.clean = function( elems, context, fragment, scripts ) { |
499 jQuery.fn.css.call( origThis, n, v ); |
459 // Set context per 1.8 logic |
500 } ); |
460 context = context || document; |
501 return this; |
461 context = !context.nodeType && context[0] || context; |
502 } |
462 context = context.ownerDocument || context; |
503 if ( typeof value === "number" ) { |
463 |
504 camelName = camelCase( name ); |
464 migrateWarn("jQuery.clean() is deprecated"); |
505 if ( !isAutoPx( camelName ) && !jQuery.cssNumber[ camelName ] ) { |
465 |
506 migrateWarn( "Number-typed values are deprecated for jQuery.fn.css( \"" + |
466 var i, elem, handleScript, jsTags, |
507 name + "\", value )" ); |
467 ret = []; |
508 } |
468 |
509 } |
469 jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes ); |
510 |
470 |
511 return oldFnCss.apply( this, arguments ); |
471 // Complex logic lifted directly from jQuery 1.8 |
512 }; |
472 if ( fragment ) { |
513 |
473 // Special handling of each script element |
514 var oldData = jQuery.data; |
474 handleScript = function( elem ) { |
515 |
475 // Check if we consider it executable |
516 jQuery.data = function( elem, name, value ) { |
476 if ( !elem.type || rscriptType.test( elem.type ) ) { |
517 var curData, sameKeys, key; |
477 // Detach the script and store it in the scripts array (if provided) or the fragment |
518 |
478 // Return truthy to indicate that it has been handled |
519 // Name can be an object, and each entry in the object is meant to be set as data |
479 return scripts ? |
520 if ( name && typeof name === "object" && arguments.length === 2 ) { |
480 scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : |
521 curData = jQuery.hasData( elem ) && oldData.call( this, elem ); |
481 fragment.appendChild( elem ); |
522 sameKeys = {}; |
482 } |
523 for ( key in name ) { |
483 }; |
524 if ( key !== camelCase( key ) ) { |
484 |
525 migrateWarn( "jQuery.data() always sets/gets camelCased names: " + key ); |
485 for ( i = 0; (elem = ret[i]) != null; i++ ) { |
526 curData[ key ] = name[ key ]; |
486 // Check if we're done after handling an executable script |
527 } else { |
487 if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { |
528 sameKeys[ key ] = name[ key ]; |
488 // Append to fragment and handle embedded scripts |
|
489 fragment.appendChild( elem ); |
|
490 if ( typeof elem.getElementsByTagName !== "undefined" ) { |
|
491 // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration |
|
492 jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); |
|
493 |
|
494 // Splice the scripts into ret after their former ancestor and advance our index beyond them |
|
495 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); |
|
496 i += jsTags.length; |
|
497 } |
|
498 } |
|
499 } |
529 } |
500 } |
530 } |
501 |
531 |
502 return ret; |
532 oldData.call( this, elem, sameKeys ); |
|
533 |
|
534 return name; |
|
535 } |
|
536 |
|
537 // If the name is transformed, look for the un-transformed name in the data object |
|
538 if ( name && typeof name === "string" && name !== camelCase( name ) ) { |
|
539 curData = jQuery.hasData( elem ) && oldData.call( this, elem ); |
|
540 if ( curData && name in curData ) { |
|
541 migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name ); |
|
542 if ( arguments.length > 2 ) { |
|
543 curData[ name ] = value; |
|
544 } |
|
545 return curData[ name ]; |
|
546 } |
|
547 } |
|
548 |
|
549 return oldData.apply( this, arguments ); |
|
550 }; |
|
551 |
|
552 // Support jQuery slim which excludes the effects module |
|
553 if ( jQuery.fx ) { |
|
554 |
|
555 var intervalValue, intervalMsg, |
|
556 oldTweenRun = jQuery.Tween.prototype.run, |
|
557 linearEasing = function( pct ) { |
|
558 return pct; |
503 }; |
559 }; |
504 } |
560 |
505 |
561 jQuery.Tween.prototype.run = function( ) { |
506 var eventAdd = jQuery.event.add, |
562 if ( jQuery.easing[ this.easing ].length > 1 ) { |
507 eventRemove = jQuery.event.remove, |
563 migrateWarn( |
508 eventTrigger = jQuery.event.trigger, |
564 "'jQuery.easing." + this.easing.toString() + "' should use only one argument" |
509 oldToggle = jQuery.fn.toggle, |
565 ); |
510 oldLive = jQuery.fn.live, |
566 |
511 oldDie = jQuery.fn.die, |
567 jQuery.easing[ this.easing ] = linearEasing; |
512 oldLoad = jQuery.fn.load, |
568 } |
513 ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess", |
569 |
514 rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ), |
570 oldTweenRun.apply( this, arguments ); |
515 rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, |
571 }; |
516 hoverHack = function( events ) { |
572 |
517 if ( typeof( events ) !== "string" || jQuery.event.special.hover ) { |
573 intervalValue = jQuery.fx.interval || 13; |
518 return events; |
574 intervalMsg = "jQuery.fx.interval is deprecated"; |
519 } |
575 |
520 if ( rhoverHack.test( events ) ) { |
576 // Support: IE9, Android <=4.4 |
521 migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'"); |
577 // Avoid false positives on browsers that lack rAF |
522 } |
578 // Don't warn if document is hidden, jQuery uses setTimeout (#292) |
523 return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); |
579 if ( window.requestAnimationFrame ) { |
524 }; |
580 Object.defineProperty( jQuery.fx, "interval", { |
525 |
581 configurable: true, |
526 // Event props removed in 1.9, put them back if needed; no practical way to warn them |
582 enumerable: true, |
527 if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) { |
583 get: function() { |
528 jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" ); |
584 if ( !window.document.hidden ) { |
529 } |
585 migrateWarn( intervalMsg ); |
530 |
586 } |
531 // Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7 |
587 return intervalValue; |
532 if ( jQuery.event.dispatch ) { |
588 }, |
533 migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" ); |
589 set: function( newValue ) { |
534 } |
590 migrateWarn( intervalMsg ); |
535 |
591 intervalValue = newValue; |
536 // Support for 'hover' pseudo-event and ajax event warnings |
592 } |
537 jQuery.event.add = function( elem, types, handler, data, selector ){ |
593 } ); |
538 if ( elem !== document && rajaxEvent.test( types ) ) { |
594 } |
539 migrateWarn( "AJAX events should be attached to document: " + types ); |
595 |
540 } |
596 } |
541 eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector ); |
597 |
542 }; |
598 var oldLoad = jQuery.fn.load, |
543 jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){ |
599 oldEventAdd = jQuery.event.add, |
544 eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes ); |
600 originalFix = jQuery.event.fix; |
|
601 |
|
602 jQuery.event.props = []; |
|
603 jQuery.event.fixHooks = {}; |
|
604 |
|
605 migrateWarnProp( jQuery.event.props, "concat", jQuery.event.props.concat, |
|
606 "jQuery.event.props.concat() is deprecated and removed" ); |
|
607 |
|
608 jQuery.event.fix = function( originalEvent ) { |
|
609 var event, |
|
610 type = originalEvent.type, |
|
611 fixHook = this.fixHooks[ type ], |
|
612 props = jQuery.event.props; |
|
613 |
|
614 if ( props.length ) { |
|
615 migrateWarn( "jQuery.event.props are deprecated and removed: " + props.join() ); |
|
616 while ( props.length ) { |
|
617 jQuery.event.addProp( props.pop() ); |
|
618 } |
|
619 } |
|
620 |
|
621 if ( fixHook && !fixHook._migrated_ ) { |
|
622 fixHook._migrated_ = true; |
|
623 migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type ); |
|
624 if ( ( props = fixHook.props ) && props.length ) { |
|
625 while ( props.length ) { |
|
626 jQuery.event.addProp( props.pop() ); |
|
627 } |
|
628 } |
|
629 } |
|
630 |
|
631 event = originalFix.call( this, originalEvent ); |
|
632 |
|
633 return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event; |
|
634 }; |
|
635 |
|
636 jQuery.event.add = function( elem, types ) { |
|
637 |
|
638 // This misses the multiple-types case but that seems awfully rare |
|
639 if ( elem === window && types === "load" && window.document.readyState === "complete" ) { |
|
640 migrateWarn( "jQuery(window).on('load'...) called after load event occurred" ); |
|
641 } |
|
642 return oldEventAdd.apply( this, arguments ); |
545 }; |
643 }; |
546 |
644 |
547 jQuery.each( [ "load", "unload", "error" ], function( _, name ) { |
645 jQuery.each( [ "load", "unload", "error" ], function( _, name ) { |
548 |
646 |
549 jQuery.fn[ name ] = function() { |
647 jQuery.fn[ name ] = function() { |
559 |
657 |
560 migrateWarn( "jQuery.fn." + name + "() is deprecated" ); |
658 migrateWarn( "jQuery.fn." + name + "() is deprecated" ); |
561 |
659 |
562 args.splice( 0, 0, name ); |
660 args.splice( 0, 0, name ); |
563 if ( arguments.length ) { |
661 if ( arguments.length ) { |
564 return this.bind.apply( this, args ); |
662 return this.on.apply( this, args ); |
565 } |
663 } |
566 |
664 |
567 // Use .triggerHandler here because: |
665 // Use .triggerHandler here because: |
568 // - load and unload events don't need to bubble, only applied to window or image |
666 // - load and unload events don't need to bubble, only applied to window or image |
569 // - error event should not bubble to window, although it does pre-1.7 |
667 // - error event should not bubble to window, although it does pre-1.7 |
570 // See http://bugs.jquery.com/ticket/11820 |
668 // See http://bugs.jquery.com/ticket/11820 |
571 this.triggerHandler.apply( this, args ); |
669 this.triggerHandler.apply( this, args ); |
572 return this; |
670 return this; |
573 }; |
671 }; |
574 |
672 |
575 }); |
673 } ); |
576 |
674 |
577 jQuery.fn.toggle = function( fn, fn2 ) { |
675 jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + |
578 |
676 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
579 // Don't mess with animation or css toggles |
677 "change select submit keydown keypress keyup contextmenu" ).split( " " ), |
580 if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) { |
678 function( _i, name ) { |
581 return oldToggle.apply( this, arguments ); |
679 |
582 } |
680 // Handle event binding |
583 migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated"); |
681 jQuery.fn[ name ] = function( data, fn ) { |
584 |
682 migrateWarn( "jQuery.fn." + name + "() event shorthand is deprecated" ); |
585 // Save reference to arguments for access in closure |
683 return arguments.length > 0 ? |
586 var args = arguments, |
684 this.on( name, null, data, fn ) : |
587 guid = fn.guid || jQuery.guid++, |
685 this.trigger( name ); |
588 i = 0, |
686 }; |
589 toggler = function( event ) { |
687 } ); |
590 // Figure out which function to execute |
688 |
591 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
689 // Trigger "ready" event only once, on document ready |
592 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
690 jQuery( function() { |
593 |
691 jQuery( window.document ).triggerHandler( "ready" ); |
594 // Make sure that clicks stop |
692 } ); |
595 event.preventDefault(); |
|
596 |
|
597 // and execute the function |
|
598 return args[ lastToggle ].apply( this, arguments ) || false; |
|
599 }; |
|
600 |
|
601 // link all the functions, so any of them can unbind this click handler |
|
602 toggler.guid = guid; |
|
603 while ( i < args.length ) { |
|
604 args[ i++ ].guid = guid; |
|
605 } |
|
606 |
|
607 return this.click( toggler ); |
|
608 }; |
|
609 |
|
610 jQuery.fn.live = function( types, data, fn ) { |
|
611 migrateWarn("jQuery.fn.live() is deprecated"); |
|
612 if ( oldLive ) { |
|
613 return oldLive.apply( this, arguments ); |
|
614 } |
|
615 jQuery( this.context ).on( types, this.selector, data, fn ); |
|
616 return this; |
|
617 }; |
|
618 |
|
619 jQuery.fn.die = function( types, fn ) { |
|
620 migrateWarn("jQuery.fn.die() is deprecated"); |
|
621 if ( oldDie ) { |
|
622 return oldDie.apply( this, arguments ); |
|
623 } |
|
624 jQuery( this.context ).off( types, this.selector || "**", fn ); |
|
625 return this; |
|
626 }; |
|
627 |
|
628 // Turn global events into document-triggered events |
|
629 jQuery.event.trigger = function( event, data, elem, onlyHandlers ){ |
|
630 if ( !elem && !rajaxEvent.test( event ) ) { |
|
631 migrateWarn( "Global events are undocumented and deprecated" ); |
|
632 } |
|
633 return eventTrigger.call( this, event, data, elem || document, onlyHandlers ); |
|
634 }; |
|
635 jQuery.each( ajaxEvents.split("|"), |
|
636 function( _, name ) { |
|
637 jQuery.event.special[ name ] = { |
|
638 setup: function() { |
|
639 var elem = this; |
|
640 |
|
641 // The document needs no shimming; must be !== for oldIE |
|
642 if ( elem !== document ) { |
|
643 jQuery.event.add( document, name + "." + jQuery.guid, function() { |
|
644 jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true ); |
|
645 }); |
|
646 jQuery._data( this, name, jQuery.guid++ ); |
|
647 } |
|
648 return false; |
|
649 }, |
|
650 teardown: function() { |
|
651 if ( this !== document ) { |
|
652 jQuery.event.remove( document, name + "." + jQuery._data( this, name ) ); |
|
653 } |
|
654 return false; |
|
655 } |
|
656 }; |
|
657 } |
|
658 ); |
|
659 |
693 |
660 jQuery.event.special.ready = { |
694 jQuery.event.special.ready = { |
661 setup: function() { |
695 setup: function() { |
662 if ( this === document ) { |
696 if ( this === window.document ) { |
663 migrateWarn( "'ready' event is deprecated" ); |
697 migrateWarn( "'ready' event is deprecated" ); |
664 } |
698 } |
665 } |
699 } |
666 }; |
700 }; |
667 |
701 |
668 var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack, |
702 jQuery.fn.extend( { |
669 oldFnFind = jQuery.fn.find; |
703 |
|
704 bind: function( types, data, fn ) { |
|
705 migrateWarn( "jQuery.fn.bind() is deprecated" ); |
|
706 return this.on( types, null, data, fn ); |
|
707 }, |
|
708 unbind: function( types, fn ) { |
|
709 migrateWarn( "jQuery.fn.unbind() is deprecated" ); |
|
710 return this.off( types, null, fn ); |
|
711 }, |
|
712 delegate: function( selector, types, data, fn ) { |
|
713 migrateWarn( "jQuery.fn.delegate() is deprecated" ); |
|
714 return this.on( types, selector, data, fn ); |
|
715 }, |
|
716 undelegate: function( selector, types, fn ) { |
|
717 migrateWarn( "jQuery.fn.undelegate() is deprecated" ); |
|
718 return arguments.length === 1 ? |
|
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 |
|
728 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 ) { |
|
731 var doc = window.document.implementation.createHTMLDocument( "" ); |
|
732 doc.body.innerHTML = html; |
|
733 return doc.body && doc.body.innerHTML; |
|
734 }, |
|
735 warnIfChanged = function( html ) { |
|
736 var changed = html.replace( rxhtmlTag, "<$1></$2>" ); |
|
737 if ( changed !== html && makeMarkup( html ) !== makeMarkup( changed ) ) { |
|
738 migrateWarn( "HTML tags must be properly nested and closed: " + html ); |
|
739 } |
|
740 }; |
|
741 |
|
742 jQuery.UNSAFE_restoreLegacyHtmlPrefilter = function() { |
|
743 jQuery.htmlPrefilter = function( html ) { |
|
744 warnIfChanged( html ); |
|
745 return html.replace( rxhtmlTag, "<$1></$2>" ); |
|
746 }; |
|
747 }; |
|
748 |
|
749 jQuery.htmlPrefilter = function( html ) { |
|
750 warnIfChanged( html ); |
|
751 return origHtmlPrefilter( html ); |
|
752 }; |
|
753 |
|
754 var oldOffset = jQuery.fn.offset; |
|
755 |
|
756 jQuery.fn.offset = function() { |
|
757 var elem = this[ 0 ]; |
|
758 |
|
759 if ( elem && ( !elem.nodeType || !elem.getBoundingClientRect ) ) { |
|
760 migrateWarn( "jQuery.fn.offset() requires a valid DOM element" ); |
|
761 return arguments.length ? this : undefined; |
|
762 } |
|
763 |
|
764 return oldOffset.apply( this, arguments ); |
|
765 }; |
|
766 |
|
767 // Support jQuery slim which excludes the ajax module |
|
768 // The jQuery.param patch is about respecting `jQuery.ajaxSettings.traditional` |
|
769 // so it doesn't make sense for the slim build. |
|
770 if ( jQuery.ajax ) { |
|
771 |
|
772 var oldParam = jQuery.param; |
|
773 |
|
774 jQuery.param = function( data, traditional ) { |
|
775 var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
|
776 |
|
777 if ( traditional === undefined && ajaxTraditional ) { |
|
778 |
|
779 migrateWarn( "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" ); |
|
780 traditional = ajaxTraditional; |
|
781 } |
|
782 |
|
783 return oldParam.call( this, data, traditional ); |
|
784 }; |
|
785 |
|
786 } |
|
787 |
|
788 var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack; |
670 |
789 |
671 jQuery.fn.andSelf = function() { |
790 jQuery.fn.andSelf = function() { |
672 migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"); |
791 migrateWarn( "jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()" ); |
673 return oldSelf.apply( this, arguments ); |
792 return oldSelf.apply( this, arguments ); |
674 }; |
793 }; |
675 |
794 |
676 jQuery.fn.find = function( selector ) { |
795 // Support jQuery slim which excludes the deferred module in jQuery 4.0+ |
677 var ret = oldFnFind.apply( this, arguments ); |
796 if ( jQuery.Deferred ) { |
678 ret.context = this.context; |
797 |
679 ret.selector = this.selector ? this.selector + " " + selector : selector; |
798 var oldDeferred = jQuery.Deferred, |
680 return ret; |
799 tuples = [ |
681 }; |
800 |
682 |
801 // Action, add listener, callbacks, .then handlers, final state |
683 |
802 [ "resolve", "done", jQuery.Callbacks( "once memory" ), |
684 // jQuery 1.6 did not support Callbacks, do not warn there |
803 jQuery.Callbacks( "once memory" ), "resolved" ], |
685 if ( jQuery.Callbacks ) { |
804 [ "reject", "fail", jQuery.Callbacks( "once memory" ), |
686 |
805 jQuery.Callbacks( "once memory" ), "rejected" ], |
687 var oldDeferred = jQuery.Deferred, |
806 [ "notify", "progress", jQuery.Callbacks( "memory" ), |
688 tuples = [ |
807 jQuery.Callbacks( "memory" ) ] |
689 // action, add listener, callbacks, .then handlers, final state |
808 ]; |
690 [ "resolve", "done", jQuery.Callbacks("once memory"), |
809 |
691 jQuery.Callbacks("once memory"), "resolved" ], |
810 jQuery.Deferred = function( func ) { |
692 [ "reject", "fail", jQuery.Callbacks("once memory"), |
811 var deferred = oldDeferred(), |
693 jQuery.Callbacks("once memory"), "rejected" ], |
812 promise = deferred.promise(); |
694 [ "notify", "progress", jQuery.Callbacks("memory"), |
813 |
695 jQuery.Callbacks("memory") ] |
814 deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) { |
696 ]; |
815 var fns = arguments; |
697 |
816 |
698 jQuery.Deferred = function( func ) { |
817 migrateWarn( "deferred.pipe() is deprecated" ); |
699 var deferred = oldDeferred(), |
818 |
700 promise = deferred.promise(); |
819 return jQuery.Deferred( function( newDefer ) { |
701 |
820 jQuery.each( tuples, function( i, tuple ) { |
702 deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) { |
821 var fn = typeof fns[ i ] === "function" && fns[ i ]; |
703 var fns = arguments; |
822 |
704 |
823 // Deferred.done(function() { bind to newDefer or newDefer.resolve }) |
705 migrateWarn( "deferred.pipe() is deprecated" ); |
824 // deferred.fail(function() { bind to newDefer or newDefer.reject }) |
706 |
825 // deferred.progress(function() { bind to newDefer or newDefer.notify }) |
707 return jQuery.Deferred(function( newDefer ) { |
826 deferred[ tuple[ 1 ] ]( function() { |
708 jQuery.each( tuples, function( i, tuple ) { |
827 var returned = fn && fn.apply( this, arguments ); |
709 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; |
828 if ( returned && typeof returned.promise === "function" ) { |
710 // deferred.done(function() { bind to newDefer or newDefer.resolve }) |
829 returned.promise() |
711 // deferred.fail(function() { bind to newDefer or newDefer.reject }) |
830 .done( newDefer.resolve ) |
712 // deferred.progress(function() { bind to newDefer or newDefer.notify }) |
831 .fail( newDefer.reject ) |
713 deferred[ tuple[1] ](function() { |
832 .progress( newDefer.notify ); |
714 var returned = fn && fn.apply( this, arguments ); |
833 } else { |
715 if ( returned && jQuery.isFunction( returned.promise ) ) { |
834 newDefer[ tuple[ 0 ] + "With" ]( |
716 returned.promise() |
835 this === promise ? newDefer.promise() : this, |
717 .done( newDefer.resolve ) |
836 fn ? [ returned ] : arguments |
718 .fail( newDefer.reject ) |
837 ); |
719 .progress( newDefer.notify ); |
838 } |
720 } else { |
839 } ); |
721 newDefer[ tuple[ 0 ] + "With" ]( |
840 } ); |
722 this === promise ? newDefer.promise() : this, |
841 fns = null; |
723 fn ? [ returned ] : arguments |
842 } ).promise(); |
724 ); |
843 |
725 } |
|
726 }); |
|
727 }); |
|
728 fns = null; |
|
729 }).promise(); |
|
730 |
|
731 }; |
|
732 |
|
733 deferred.isResolved = function() { |
|
734 migrateWarn( "deferred.isResolved is deprecated" ); |
|
735 return deferred.state() === "resolved"; |
|
736 }; |
|
737 |
|
738 deferred.isRejected = function() { |
|
739 migrateWarn( "deferred.isRejected is deprecated" ); |
|
740 return deferred.state() === "rejected"; |
|
741 }; |
|
742 |
|
743 if ( func ) { |
|
744 func.call( deferred, deferred ); |
|
745 } |
|
746 |
|
747 return deferred; |
|
748 }; |
844 }; |
749 |
845 |
750 } |
846 if ( func ) { |
751 |
847 func.call( deferred, deferred ); |
752 })( jQuery, window ); |
848 } |
|
849 |
|
850 return deferred; |
|
851 }; |
|
852 |
|
853 // Preserve handler of uncaught exceptions in promise chains |
|
854 jQuery.Deferred.exceptionHook = oldDeferred.exceptionHook; |
|
855 |
|
856 } |
|
857 |
|
858 return jQuery; |
|
859 } ); |