1/*! 2 * jQuery Migrate - v3.1.0 - 2019-06-08 3 * Copyright OpenJS Foundation and other contributors 4 */ 5;( function( factory ) { 6 if ( typeof define === "function" && define.amd ) { 7 8 // AMD. Register as an anonymous module. 9 define( [ "jquery" ], function ( jQuery ) { 10 return factory( jQuery, window ); 11 } ); 12 } else if ( typeof module === "object" && module.exports ) { 13 14 // Node/CommonJS 15 // eslint-disable-next-line no-undef 16 module.exports = factory( require( "jquery" ), window ); 17 } else { 18 19 // Browser globals 20 factory( jQuery, window ); 21 } 22} )( function( jQuery, window ) { 23"use strict"; 24 25 26jQuery.migrateVersion = "3.1.0"; 27 28/* exported jQueryVersionSince, compareVersions */ 29 30// Returns 0 if v1 == v2, -1 if v1 < v2, 1 if v1 > v2 31function compareVersions( v1, v2 ) { 32 var rVersionParts = /^(\d+)\.(\d+)\.(\d+)/, 33 v1p = rVersionParts.exec( v1 ) || [ ], 34 v2p = rVersionParts.exec( v2 ) || [ ]; 35 36 for ( var 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 47function jQueryVersionSince( version ) { 48 return compareVersions( jQuery.fn.jquery, version ) >= 0; 49} 50 51/* exported migrateWarn, migrateWarnFunc, migrateWarnProp */ 52 53( function() { 54 55 // Support: IE9 only 56 // IE9 only creates console object when dev tools are first opened 57 // IE9 console is a host object, callable but doesn't have .apply() 58 if ( !window.console || !window.console.log ) { 59 return; 60 } 61 62 // Need jQuery 3.0.0+ and no older Migrate loaded 63 if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) { 64 window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" ); 65 } 66 if ( jQuery.migrateWarnings ) { 67 window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" ); 68 } 69 70 // Show a message on the console so devs know we're active 71 window.console.log( "JQMIGRATE: Migrate is installed" + 72 ( jQuery.migrateMute ? "" : " with logging active" ) + 73 ", version " + jQuery.migrateVersion ); 74 75} )(); 76 77var warnedAbout = {}; 78 79// List of warnings already given; public read only 80jQuery.migrateWarnings = []; 81 82// Set to false to disable traces that appear with warnings 83if ( jQuery.migrateTrace === undefined ) { 84 jQuery.migrateTrace = true; 85} 86 87// Forget any warnings we've already given; public 88jQuery.migrateReset = function() { 89 warnedAbout = {}; 90 jQuery.migrateWarnings.length = 0; 91}; 92 93function migrateWarn( msg ) { 94 var console = window.console; 95 if ( !warnedAbout[ msg ] ) { 96 warnedAbout[ msg ] = true; 97 jQuery.migrateWarnings.push( msg ); 98 if ( console && console.warn && !jQuery.migrateMute ) { 99 console.warn( "JQMIGRATE: " + msg ); 100 if ( jQuery.migrateTrace && console.trace ) { 101 console.trace(); 102 } 103 } 104 } 105} 106 107function migrateWarnProp( obj, prop, value, msg ) { 108 Object.defineProperty( obj, prop, { 109 configurable: true, 110 enumerable: true, 111 get: function() { 112 migrateWarn( msg ); 113 return value; 114 }, 115 set: function( newValue ) { 116 migrateWarn( msg ); 117 value = newValue; 118 } 119 } ); 120} 121 122function migrateWarnFunc( obj, prop, newFunc, msg ) { 123 obj[ prop ] = function() { 124 migrateWarn( msg ); 125 return newFunc.apply( this, arguments ); 126 }; 127} 128 129if ( window.document.compatMode === "BackCompat" ) { 130 131 // JQuery has never supported or tested Quirks Mode 132 migrateWarn( "jQuery is not compatible with Quirks Mode" ); 133} 134 135 136var oldInit = jQuery.fn.init, 137 oldIsNumeric = jQuery.isNumeric, 138 oldFind = jQuery.find, 139 rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, 140 rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g; 141 142jQuery.fn.init = function( arg1 ) { 143 var args = Array.prototype.slice.call( arguments ); 144 145 if ( typeof arg1 === "string" && arg1 === "#" ) { 146 147 // JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0 148 migrateWarn( "jQuery( '#' ) is not a valid selector" ); 149 args[ 0 ] = []; 150 } 151 152 return oldInit.apply( this, args ); 153}; 154jQuery.fn.init.prototype = jQuery.fn; 155 156jQuery.find = function( selector ) { 157 var args = Array.prototype.slice.call( arguments ); 158 159 // Support: PhantomJS 1.x 160 // String#match fails to match when used with a //g RegExp, only on some strings 161 if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { 162 163 // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0 164 // First see if qS thinks it's a valid selector, if so avoid a false positive 165 try { 166 window.document.querySelector( selector ); 167 } catch ( err1 ) { 168 169 // Didn't *look* valid to qSA, warn and try quoting what we think is the value 170 selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) { 171 return "[" + attr + op + "\"" + value + "\"]"; 172 } ); 173 174 // If the regexp *may* have created an invalid selector, don't update it 175 // Note that there may be false alarms if selector uses jQuery extensions 176 try { 177 window.document.querySelector( selector ); 178 migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] ); 179 args[ 0 ] = selector; 180 } catch ( err2 ) { 181 migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] ); 182 } 183 } 184 } 185 186 return oldFind.apply( this, args ); 187}; 188 189// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) 190var findProp; 191for ( findProp in oldFind ) { 192 if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { 193 jQuery.find[ findProp ] = oldFind[ findProp ]; 194 } 195} 196 197// The number of elements contained in the matched element set 198jQuery.fn.size = function() { 199 migrateWarn( "jQuery.fn.size() is deprecated and removed; use the .length property" ); 200 return this.length; 201}; 202 203jQuery.parseJSON = function() { 204 migrateWarn( "jQuery.parseJSON is deprecated; use JSON.parse" ); 205 return JSON.parse.apply( null, arguments ); 206}; 207 208jQuery.isNumeric = function( val ) { 209 210 // The jQuery 2.2.3 implementation of isNumeric 211 function isNumeric2( obj ) { 212 var realStringObj = obj && obj.toString(); 213 return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; 214 } 215 216 var newValue = oldIsNumeric( val ), 217 oldValue = isNumeric2( val ); 218 219 if ( newValue !== oldValue ) { 220 migrateWarn( "jQuery.isNumeric() should not be called on constructed objects" ); 221 } 222 223 return oldValue; 224}; 225 226if ( jQueryVersionSince( "3.3.0" ) ) { 227 migrateWarnFunc( jQuery, "isWindow", 228 function( obj ) { 229 return obj != null && obj === obj.window; 230 }, 231 "jQuery.isWindow() is deprecated" 232 ); 233} 234 235migrateWarnFunc( jQuery, "holdReady", jQuery.holdReady, 236 "jQuery.holdReady is deprecated" ); 237 238migrateWarnFunc( jQuery, "unique", jQuery.uniqueSort, 239 "jQuery.unique is deprecated; use jQuery.uniqueSort" ); 240 241// Now jQuery.expr.pseudos is the standard incantation 242migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos, 243 "jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" ); 244migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos, 245 "jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" ); 246 247// Prior to jQuery 3.2 there were internal refs so we don't warn there 248if ( jQueryVersionSince( "3.2.0" ) ) { 249 migrateWarnFunc( jQuery, "nodeName", jQuery.nodeName, 250 "jQuery.nodeName is deprecated" ); 251} 252 253 254var oldAjax = jQuery.ajax; 255 256jQuery.ajax = function( ) { 257 var jQXHR = oldAjax.apply( this, arguments ); 258 259 // Be sure we got a jQXHR (e.g., not sync) 260 if ( jQXHR.promise ) { 261 migrateWarnFunc( jQXHR, "success", jQXHR.done, 262 "jQXHR.success is deprecated and removed" ); 263 migrateWarnFunc( jQXHR, "error", jQXHR.fail, 264 "jQXHR.error is deprecated and removed" ); 265 migrateWarnFunc( jQXHR, "complete", jQXHR.always, 266 "jQXHR.complete is deprecated and removed" ); 267 } 268 269 return jQXHR; 270}; 271 272 273var oldRemoveAttr = jQuery.fn.removeAttr, 274 oldToggleClass = jQuery.fn.toggleClass, 275 rmatchNonSpace = /\S+/g; 276 277jQuery.fn.removeAttr = function( name ) { 278 var self = this; 279 280 jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) { 281 if ( jQuery.expr.match.bool.test( attr ) ) { 282 migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr ); 283 self.prop( attr, false ); 284 } 285 } ); 286 287 return oldRemoveAttr.apply( this, arguments ); 288}; 289 290jQuery.fn.toggleClass = function( state ) { 291 292 // Only deprecating no-args or single boolean arg 293 if ( state !== undefined && typeof state !== "boolean" ) { 294 return oldToggleClass.apply( this, arguments ); 295 } 296 297 migrateWarn( "jQuery.fn.toggleClass( boolean ) is deprecated" ); 298 299 // Toggle entire class name of each element 300 return this.each( function() { 301 var className = this.getAttribute && this.getAttribute( "class" ) || ""; 302 303 if ( className ) { 304 jQuery.data( this, "__className__", className ); 305 } 306 307 // If the element has a class name or if we're passed `false`, 308 // then remove the whole classname (if there was one, the above saved it). 309 // Otherwise bring back whatever was previously saved (if anything), 310 // falling back to the empty string if nothing was stored. 311 if ( this.setAttribute ) { 312 this.setAttribute( "class", 313 className || state === false ? 314 "" : 315 jQuery.data( this, "__className__" ) || "" 316 ); 317 } 318 } ); 319}; 320 321 322var internalSwapCall = false; 323 324// If this version of jQuery has .swap(), don't false-alarm on internal uses 325if ( jQuery.swap ) { 326 jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) { 327 var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get; 328 329 if ( oldHook ) { 330 jQuery.cssHooks[ name ].get = function() { 331 var ret; 332 333 internalSwapCall = true; 334 ret = oldHook.apply( this, arguments ); 335 internalSwapCall = false; 336 return ret; 337 }; 338 } 339 } ); 340} 341 342jQuery.swap = function( elem, options, callback, args ) { 343 var ret, name, 344 old = {}; 345 346 if ( !internalSwapCall ) { 347 migrateWarn( "jQuery.swap() is undocumented and deprecated" ); 348 } 349 350 // Remember the old values, and insert the new ones 351 for ( name in options ) { 352 old[ name ] = elem.style[ name ]; 353 elem.style[ name ] = options[ name ]; 354 } 355 356 ret = callback.apply( elem, args || [] ); 357 358 // Revert the old values 359 for ( name in options ) { 360 elem.style[ name ] = old[ name ]; 361 } 362 363 return ret; 364}; 365 366var oldData = jQuery.data; 367 368jQuery.data = function( elem, name, value ) { 369 var curData; 370 371 // Name can be an object, and each entry in the object is meant to be set as data 372 if ( name && typeof name === "object" && arguments.length === 2 ) { 373 curData = jQuery.hasData( elem ) && oldData.call( this, elem ); 374 var sameKeys = {}; 375 for ( var key in name ) { 376 if ( key !== jQuery.camelCase( key ) ) { 377 migrateWarn( "jQuery.data() always sets/gets camelCased names: " + key ); 378 curData[ key ] = name[ key ]; 379 } else { 380 sameKeys[ key ] = name[ key ]; 381 } 382 } 383 384 oldData.call( this, elem, sameKeys ); 385 386 return name; 387 } 388 389 // If the name is transformed, look for the un-transformed name in the data object 390 if ( name && typeof name === "string" && name !== jQuery.camelCase( name ) ) { 391 curData = jQuery.hasData( elem ) && oldData.call( this, elem ); 392 if ( curData && name in curData ) { 393 migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name ); 394 if ( arguments.length > 2 ) { 395 curData[ name ] = value; 396 } 397 return curData[ name ]; 398 } 399 } 400 401 return oldData.apply( this, arguments ); 402}; 403 404var oldTweenRun = jQuery.Tween.prototype.run; 405var linearEasing = function( pct ) { 406 return pct; 407 }; 408 409jQuery.Tween.prototype.run = function( ) { 410 if ( jQuery.easing[ this.easing ].length > 1 ) { 411 migrateWarn( 412 "'jQuery.easing." + this.easing.toString() + "' should use only one argument" 413 ); 414 415 jQuery.easing[ this.easing ] = linearEasing; 416 } 417 418 oldTweenRun.apply( this, arguments ); 419}; 420 421var intervalValue = jQuery.fx.interval || 13, 422 intervalMsg = "jQuery.fx.interval is deprecated"; 423 424// Support: IE9, Android <=4.4 425// Avoid false positives on browsers that lack rAF 426// Don't warn if document is hidden, jQuery uses setTimeout (#292) 427if ( window.requestAnimationFrame ) { 428 Object.defineProperty( jQuery.fx, "interval", { 429 configurable: true, 430 enumerable: true, 431 get: function() { 432 if ( !window.document.hidden ) { 433 migrateWarn( intervalMsg ); 434 } 435 return intervalValue; 436 }, 437 set: function( newValue ) { 438 migrateWarn( intervalMsg ); 439 intervalValue = newValue; 440 } 441 } ); 442} 443 444var oldLoad = jQuery.fn.load, 445 oldEventAdd = jQuery.event.add, 446 originalFix = jQuery.event.fix; 447 448jQuery.event.props = []; 449jQuery.event.fixHooks = {}; 450 451migrateWarnProp( jQuery.event.props, "concat", jQuery.event.props.concat, 452 "jQuery.event.props.concat() is deprecated and removed" ); 453 454jQuery.event.fix = function( originalEvent ) { 455 var event, 456 type = originalEvent.type, 457 fixHook = this.fixHooks[ type ], 458 props = jQuery.event.props; 459 460 if ( props.length ) { 461 migrateWarn( "jQuery.event.props are deprecated and removed: " + props.join() ); 462 while ( props.length ) { 463 jQuery.event.addProp( props.pop() ); 464 } 465 } 466 467 if ( fixHook && !fixHook._migrated_ ) { 468 fixHook._migrated_ = true; 469 migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type ); 470 if ( ( props = fixHook.props ) && props.length ) { 471 while ( props.length ) { 472 jQuery.event.addProp( props.pop() ); 473 } 474 } 475 } 476 477 event = originalFix.call( this, originalEvent ); 478 479 return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event; 480}; 481 482jQuery.event.add = function( elem, types ) { 483 484 // This misses the multiple-types case but that seems awfully rare 485 if ( elem === window && types === "load" && window.document.readyState === "complete" ) { 486 migrateWarn( "jQuery(window).on('load'...) called after load event occurred" ); 487 } 488 return oldEventAdd.apply( this, arguments ); 489}; 490 491jQuery.each( [ "load", "unload", "error" ], function( _, name ) { 492 493 jQuery.fn[ name ] = function() { 494 var args = Array.prototype.slice.call( arguments, 0 ); 495 496 // If this is an ajax load() the first arg should be the string URL; 497 // technically this could also be the "Anything" arg of the event .load() 498 // which just goes to show why this dumb signature has been deprecated! 499 // jQuery custom builds that exclude the Ajax module justifiably die here. 500 if ( name === "load" && typeof args[ 0 ] === "string" ) { 501 return oldLoad.apply( this, args ); 502 } 503 504 migrateWarn( "jQuery.fn." + name + "() is deprecated" ); 505 506 args.splice( 0, 0, name ); 507 if ( arguments.length ) { 508 return this.on.apply( this, args ); 509 } 510 511 // Use .triggerHandler here because: 512 // - load and unload events don't need to bubble, only applied to window or image 513 // - error event should not bubble to window, although it does pre-1.7 514 // See http://bugs.jquery.com/ticket/11820 515 this.triggerHandler.apply( this, args ); 516 return this; 517 }; 518 519} ); 520 521jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + 522 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 523 "change select submit keydown keypress keyup contextmenu" ).split( " " ), 524 function( _i, name ) { 525 526 // Handle event binding 527 jQuery.fn[ name ] = function( data, fn ) { 528 migrateWarn( "jQuery.fn." + name + "() event shorthand is deprecated" ); 529 return arguments.length > 0 ? 530 this.on( name, null, data, fn ) : 531 this.trigger( name ); 532 }; 533} ); 534 535// Trigger "ready" event only once, on document ready 536jQuery( function() { 537 jQuery( window.document ).triggerHandler( "ready" ); 538} ); 539 540jQuery.event.special.ready = { 541 setup: function() { 542 if ( this === window.document ) { 543 migrateWarn( "'ready' event is deprecated" ); 544 } 545 } 546}; 547 548jQuery.fn.extend( { 549 550 bind: function( types, data, fn ) { 551 migrateWarn( "jQuery.fn.bind() is deprecated" ); 552 return this.on( types, null, data, fn ); 553 }, 554 unbind: function( types, fn ) { 555 migrateWarn( "jQuery.fn.unbind() is deprecated" ); 556 return this.off( types, null, fn ); 557 }, 558 delegate: function( selector, types, data, fn ) { 559 migrateWarn( "jQuery.fn.delegate() is deprecated" ); 560 return this.on( types, selector, data, fn ); 561 }, 562 undelegate: function( selector, types, fn ) { 563 migrateWarn( "jQuery.fn.undelegate() is deprecated" ); 564 return arguments.length === 1 ? 565 this.off( selector, "**" ) : 566 this.off( types, selector || "**", fn ); 567 }, 568 hover: function( fnOver, fnOut ) { 569 migrateWarn( "jQuery.fn.hover() is deprecated" ); 570 return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver ); 571 } 572} ); 573 574 575var oldOffset = jQuery.fn.offset; 576 577jQuery.fn.offset = function() { 578 var docElem, 579 elem = this[ 0 ], 580 origin = { top: 0, left: 0 }; 581 582 if ( !elem || !elem.nodeType ) { 583 migrateWarn( "jQuery.fn.offset() requires a valid DOM element" ); 584 return origin; 585 } 586 587 docElem = ( elem.ownerDocument || window.document ).documentElement; 588 if ( !jQuery.contains( docElem, elem ) ) { 589 migrateWarn( "jQuery.fn.offset() requires an element connected to a document" ); 590 return origin; 591 } 592 593 return oldOffset.apply( this, arguments ); 594}; 595 596 597var oldParam = jQuery.param; 598 599jQuery.param = function( data, traditional ) { 600 var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; 601 602 if ( traditional === undefined && ajaxTraditional ) { 603 604 migrateWarn( "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" ); 605 traditional = ajaxTraditional; 606 } 607 608 return oldParam.call( this, data, traditional ); 609}; 610 611var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack; 612 613jQuery.fn.andSelf = function() { 614 migrateWarn( "jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()" ); 615 return oldSelf.apply( this, arguments ); 616}; 617 618 619var oldDeferred = jQuery.Deferred, 620 tuples = [ 621 622 // Action, add listener, callbacks, .then handlers, final state 623 [ "resolve", "done", jQuery.Callbacks( "once memory" ), 624 jQuery.Callbacks( "once memory" ), "resolved" ], 625 [ "reject", "fail", jQuery.Callbacks( "once memory" ), 626 jQuery.Callbacks( "once memory" ), "rejected" ], 627 [ "notify", "progress", jQuery.Callbacks( "memory" ), 628 jQuery.Callbacks( "memory" ) ] 629 ]; 630 631jQuery.Deferred = function( func ) { 632 var deferred = oldDeferred(), 633 promise = deferred.promise(); 634 635 deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) { 636 var fns = arguments; 637 638 migrateWarn( "deferred.pipe() is deprecated" ); 639 640 return jQuery.Deferred( function( newDefer ) { 641 jQuery.each( tuples, function( i, tuple ) { 642 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; 643 644 // Deferred.done(function() { bind to newDefer or newDefer.resolve }) 645 // deferred.fail(function() { bind to newDefer or newDefer.reject }) 646 // deferred.progress(function() { bind to newDefer or newDefer.notify }) 647 deferred[ tuple[ 1 ] ]( function() { 648 var returned = fn && fn.apply( this, arguments ); 649 if ( returned && jQuery.isFunction( returned.promise ) ) { 650 returned.promise() 651 .done( newDefer.resolve ) 652 .fail( newDefer.reject ) 653 .progress( newDefer.notify ); 654 } else { 655 newDefer[ tuple[ 0 ] + "With" ]( 656 this === promise ? newDefer.promise() : this, 657 fn ? [ returned ] : arguments 658 ); 659 } 660 } ); 661 } ); 662 fns = null; 663 } ).promise(); 664 665 }; 666 667 if ( func ) { 668 func.call( deferred, deferred ); 669 } 670 671 return deferred; 672}; 673 674// Preserve handler of uncaught exceptions in promise chains 675jQuery.Deferred.exceptionHook = oldDeferred.exceptionHook; 676 677return jQuery; 678} ); 679