JAVASCRIPT   48
jQuery Migrate with define()
Guest on 10th November 2021 06:40:57 AM


  1. /*!
  2.  * jQuery Migrate - v3.3.2 - 2020-11-17T23:22Z
  3.  * Copyright OpenJS Foundation and other contributors
  4.  */
  5. define("jquery-migrate", ['jquery'], function( jQuery ) {
  6. "use strict";
  7.  
  8. jQuery.migrateVersion = "3.3.2";
  9.  
  10. // Returns 0 if v1 == v2, -1 if v1 < v2, 1 if v1 > v2
  11. function compareVersions( v1, v2 ) {
  12.         var i,
  13.                 rVersionParts = /^(\d+)\.(\d+)\.(\d+)/,
  14.                 v1p = rVersionParts.exec( v1 ) || [ ],
  15.                 v2p = rVersionParts.exec( v2 ) || [ ];
  16.  
  17.         for ( i = 1; i <= 3; i++ ) {
  18.                 if ( +v1p[ i ] > +v2p[ i ] ) {
  19.                         return 1;
  20.                 }
  21.                 if ( +v1p[ i ] < +v2p[ i ] ) {
  22.                         return -1;
  23.                 }
  24.         }
  25.         return 0;
  26. }
  27.  
  28. function jQueryVersionSince( version ) {
  29.         return compareVersions( jQuery.fn.jquery, version ) >= 0;
  30. }
  31.  
  32. ( function() {
  33.  
  34.         // Support: IE9 only
  35.         // IE9 only creates console object when dev tools are first opened
  36.         // IE9 console is a host object, callable but doesn't have .apply()
  37.         if ( !window.console || !window.console.log ) {
  38.                 return;
  39.         }
  40.  
  41.         // Need jQuery 3.0.0+ and no older Migrate loaded
  42.         if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) {
  43.                 window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
  44.         }
  45.         if ( jQuery.migrateWarnings ) {
  46.                 window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" );
  47.         }
  48.  
  49.         // Show a message on the console so devs know we're active
  50.         window.console.log( "JQMIGRATE: Migrate is installed" +
  51.                 ( jQuery.migrateMute ? "" : " with logging active" ) +
  52.                 ", version " + jQuery.migrateVersion );
  53.  
  54. } )();
  55.  
  56. var warnedAbout = {};
  57.  
  58. // By default each warning is only reported once.
  59. jQuery.migrateDeduplicateWarnings = true;
  60.  
  61. // List of warnings already given; public read only
  62. jQuery.migrateWarnings = [];
  63.  
  64. // Set to false to disable traces that appear with warnings
  65. if ( jQuery.migrateTrace === undefined ) {
  66.         jQuery.migrateTrace = true;
  67. }
  68.  
  69. // Forget any warnings we've already given; public
  70. jQuery.migrateReset = function() {
  71.         warnedAbout = {};
  72.         jQuery.migrateWarnings.length = 0;
  73. };
  74.  
  75. function migrateWarn( msg ) {
  76.         var console = window.console;
  77.         if ( !jQuery.migrateDeduplicateWarnings || !warnedAbout[ msg ] ) {
  78.                 warnedAbout[ msg ] = true;
  79.                 jQuery.migrateWarnings.push( msg );
  80.                 if ( console && console.warn && !jQuery.migrateMute ) {
  81.                         console.warn( "JQMIGRATE: " + msg );
  82.                         if ( jQuery.migrateTrace && console.trace ) {
  83.                                 console.trace();
  84.                         }
  85.                 }
  86.         }
  87. }
  88.  
  89. function migrateWarnProp( obj, prop, value, msg ) {
  90.         Object.defineProperty( obj, prop, {
  91.                 configurable: true,
  92.                 enumerable: true,
  93.                 get: function() {
  94.                         migrateWarn( msg );
  95.                         return value;
  96.                 },
  97.                 set: function( newValue ) {
  98.                         migrateWarn( msg );
  99.                         value = newValue;
  100.                 }
  101.         } );
  102. }
  103.  
  104. function migrateWarnFunc( obj, prop, newFunc, msg ) {
  105.         obj[ prop ] = function() {
  106.                 migrateWarn( msg );
  107.                 return newFunc.apply( this, arguments );
  108.         };
  109. }
  110.  
  111. if ( window.document.compatMode === "BackCompat" ) {
  112.  
  113.         // JQuery has never supported or tested Quirks Mode
  114.         migrateWarn( "jQuery is not compatible with Quirks Mode" );
  115. }
  116.  
  117. var findProp,
  118.         class2type = {},
  119.         oldInit = jQuery.fn.init,
  120.         oldFind = jQuery.find,
  121.  
  122.         rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
  123.         rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
  124.  
  125.         // Support: Android <=4.0 only
  126.         // Make sure we trim BOM and NBSP
  127.         rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  128.  
  129. jQuery.fn.init = function( arg1 ) {
  130.         var args = Array.prototype.slice.call( arguments );
  131.  
  132.         if ( typeof arg1 === "string" && arg1 === "#" ) {
  133.  
  134.                 // JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
  135.                 migrateWarn( "jQuery( '#' ) is not a valid selector" );
  136.                 args[ 0 ] = [];
  137.         }
  138.  
  139.         return oldInit.apply( this, args );
  140. };
  141. jQuery.fn.init.prototype = jQuery.fn;
  142.  
  143. jQuery.find = function( selector ) {
  144.         var args = Array.prototype.slice.call( arguments );
  145.  
  146.         // Support: PhantomJS 1.x
  147.         // String#match fails to match when used with a //g RegExp, only on some strings
  148.         if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
  149.  
  150.                 // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
  151.                 // First see if qS thinks it's a valid selector, if so avoid a false positive
  152.                 try {
  153.                         window.document.querySelector( selector );
  154.                 } catch ( err1 ) {
  155.  
  156.                         // Didn't *look* valid to qSA, warn and try quoting what we think is the value
  157.                         selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
  158.                                 return "[" + attr + op + "\"" + value + "\"]";
  159.                         } );
  160.  
  161.                         // If the regexp *may* have created an invalid selector, don't update it
  162.                         // Note that there may be false alarms if selector uses jQuery extensions
  163.                         try {
  164.                                 window.document.querySelector( selector );
  165.                                 migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
  166.                                 args[ 0 ] = selector;
  167.                         } catch ( err2 ) {
  168.                                 migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] );
  169.                         }
  170.                 }
  171.         }
  172.  
  173.         return oldFind.apply( this, args );
  174. };
  175.  
  176. // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
  177. for ( findProp in oldFind ) {
  178.         if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {
  179.                 jQuery.find[ findProp ] = oldFind[ findProp ];
  180.         }
  181. }
  182.  
  183. // The number of elements contained in the matched element set
  184. migrateWarnFunc( jQuery.fn, "size", function() {
  185.         return this.length;
  186. },
  187. "jQuery.fn.size() is deprecated and removed; use the .length property" );
  188.  
  189. migrateWarnFunc( jQuery, "parseJSON", function() {
  190.         return JSON.parse.apply( null, arguments );
  191. },
  192. "jQuery.parseJSON is deprecated; use JSON.parse" );
  193.  
  194. migrateWarnFunc( jQuery, "holdReady", jQuery.holdReady,
  195.         "jQuery.holdReady is deprecated" );
  196.  
  197. migrateWarnFunc( jQuery, "unique", jQuery.uniqueSort,
  198.         "jQuery.unique is deprecated; use jQuery.uniqueSort" );
  199.  
  200. // Now jQuery.expr.pseudos is the standard incantation
  201. migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos,
  202.         "jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" );
  203. migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos,
  204.         "jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" );
  205.  
  206. // Prior to jQuery 3.1.1 there were internal refs so we don't warn there
  207. if ( jQueryVersionSince( "3.1.1" ) ) {
  208.         migrateWarnFunc( jQuery, "trim", function( text ) {
  209.                 return text == null ?
  210.                         "" :
  211.                         ( text + "" ).replace( rtrim, "" );
  212.         },
  213.         "jQuery.trim is deprecated; use String.prototype.trim" );
  214. }
  215.  
  216. // Prior to jQuery 3.2 there were internal refs so we don't warn there
  217. if ( jQueryVersionSince( "3.2.0" ) ) {
  218.         migrateWarnFunc( jQuery, "nodeName", function( elem, name ) {
  219.                 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  220.         },
  221.         "jQuery.nodeName is deprecated" );
  222.  
  223.         migrateWarnFunc( jQuery, "isArray", Array.isArray,
  224.                 "jQuery.isArray is deprecated; use Array.isArray"
  225.         );
  226. }
  227.  
  228. if ( jQueryVersionSince( "3.3.0" ) ) {
  229.  
  230.         migrateWarnFunc( jQuery, "isNumeric", function( obj ) {
  231.  
  232.                         // As of jQuery 3.0, isNumeric is limited to
  233.                         // strings and numbers (primitives or objects)
  234.                         // that can be coerced to finite numbers (gh-2662)
  235.                         var type = typeof obj;
  236.                         return ( type === "number" || type === "string" ) &&
  237.  
  238.                                 // parseFloat NaNs numeric-cast false positives ("")
  239.                                 // ...but misinterprets leading-number strings, e.g. hex literals ("0x...")
  240.                                 // subtraction forces infinities to NaN
  241.                                 !isNaN( obj - parseFloat( obj ) );
  242.                 },
  243.                 "jQuery.isNumeric() is deprecated"
  244.         );
  245.  
  246.         // Populate the class2type map
  247.         jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".
  248.                 split( " " ),
  249.         function( _, name ) {
  250.                 class2type[ "[object " + name + "]" ] = name.toLowerCase();
  251.         } );
  252.  
  253.         migrateWarnFunc( jQuery, "type", function( obj ) {
  254.                 if ( obj == null ) {
  255.                         return obj + "";
  256.                 }
  257.  
  258.                 // Support: Android <=2.3 only (functionish RegExp)
  259.                 return typeof obj === "object" || typeof obj === "function" ?
  260.                         class2type[ Object.prototype.toString.call( obj ) ] || "object" :
  261.                         typeof obj;
  262.         },
  263.         "jQuery.type is deprecated" );
  264.  
  265.         migrateWarnFunc( jQuery, "isFunction",
  266.                 function( obj ) {
  267.                         return typeof obj === "function";
  268.                 },
  269.                 "jQuery.isFunction() is deprecated" );
  270.  
  271.         migrateWarnFunc( jQuery, "isWindow",
  272.                 function( obj ) {
  273.                         return obj != null && obj === obj.window;
  274.                 },
  275.                 "jQuery.isWindow() is deprecated"
  276.         );
  277. }
  278.  
  279. // Support jQuery slim which excludes the ajax module
  280. if ( jQuery.ajax ) {
  281.  
  282. var oldAjax = jQuery.ajax,
  283.         rjsonp = /(=)\?(?=&|$)|\?\?/;
  284.  
  285. jQuery.ajax = function( ) {
  286.         var jQXHR = oldAjax.apply( this, arguments );
  287.  
  288.         // Be sure we got a jQXHR (e.g., not sync)
  289.         if ( jQXHR.promise ) {
  290.                 migrateWarnFunc( jQXHR, "success", jQXHR.done,
  291.                         "jQXHR.success is deprecated and removed" );
  292.                 migrateWarnFunc( jQXHR, "error", jQXHR.fail,
  293.                         "jQXHR.error is deprecated and removed" );
  294.                 migrateWarnFunc( jQXHR, "complete", jQXHR.always,
  295.                         "jQXHR.complete is deprecated and removed" );
  296.         }
  297.  
  298.         return jQXHR;
  299. };
  300.  
  301. // Only trigger the logic in jQuery <4 as the JSON-to-JSONP auto-promotion
  302. // behavior is gone in jQuery 4.0 and as it has security implications, we don't
  303. // want to restore the legacy behavior.
  304. if ( !jQueryVersionSince( "4.0.0" ) ) {
  305.  
  306.         // Register this prefilter before the jQuery one. Otherwise, a promoted
  307.         // request is transformed into one with the script dataType and we can't
  308.         // catch it anymore.
  309.         jQuery.ajaxPrefilter( "+json", function( s ) {
  310.  
  311.                 // Warn if JSON-to-JSONP auto-promotion happens.
  312.                 if ( s.jsonp !== false && ( rjsonp.test( s.url ) ||
  313.                                 typeof s.data === "string" &&
  314.                                 ( s.contentType || "" )
  315.                                         .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  316.                                 rjsonp.test( s.data )
  317.                 ) ) {
  318.                         migrateWarn( "JSON-to-JSONP auto-promotion is deprecated" );
  319.                 }
  320.         } );
  321. }
  322.  
  323. }
  324.  
  325. var oldRemoveAttr = jQuery.fn.removeAttr,
  326.         oldToggleClass = jQuery.fn.toggleClass,
  327.         rmatchNonSpace = /\S+/g;
  328.  
  329. jQuery.fn.removeAttr = function( name ) {
  330.         var self = this;
  331.  
  332.         jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) {
  333.                 if ( jQuery.expr.match.bool.test( attr ) ) {
  334.                         migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr );
  335.                         self.prop( attr, false );
  336.                 }
  337.         } );
  338.  
  339.         return oldRemoveAttr.apply( this, arguments );
  340. };
  341.  
  342. jQuery.fn.toggleClass = function( state ) {
  343.  
  344.         // Only deprecating no-args or single boolean arg
  345.         if ( state !== undefined && typeof state !== "boolean" ) {
  346.                 return oldToggleClass.apply( this, arguments );
  347.         }
  348.  
  349.         migrateWarn( "jQuery.fn.toggleClass( boolean ) is deprecated" );
  350.  
  351.         // Toggle entire class name of each element
  352.         return this.each( function() {
  353.                 var className = this.getAttribute && this.getAttribute( "class" ) || "";
  354.  
  355.                 if ( className ) {
  356.                         jQuery.data( this, "__className__", className );
  357.                 }
  358.  
  359.                 // If the element has a class name or if we're passed `false`,
  360.                 // then remove the whole classname (if there was one, the above saved it).
  361.                 // Otherwise bring back whatever was previously saved (if anything),
  362.                 // falling back to the empty string if nothing was stored.
  363.                 if ( this.setAttribute ) {
  364.                         this.setAttribute( "class",
  365.                                 className || state === false ?
  366.                                 "" :
  367.                                 jQuery.data( this, "__className__" ) || ""
  368.                         );
  369.                 }
  370.         } );
  371. };
  372.  
  373. function camelCase( string ) {
  374.         return string.replace( /-([a-z])/g, function( _, letter ) {
  375.                 return letter.toUpperCase();
  376.         } );
  377. }
  378.  
  379. var oldFnCss,
  380.         internalSwapCall = false,
  381.         ralphaStart = /^[a-z]/,
  382.  
  383.         // The regex visualized:
  384.         //
  385.         //                         /----------\
  386.         //                        |            |    /-------\
  387.         //                        |  / Top  \  |   |         |
  388.         //         /--- Border ---+-| Right  |-+---+- Width -+---\
  389.         //        |                 | Bottom |                    |
  390.         //        |                  \ Left /                     |
  391.         //        |                                               |
  392.         //        |                              /----------\     |
  393.         //        |          /-------------\    |            |    |- END
  394.         //        |         |               |   |  / Top  \  |    |
  395.         //        |         |  / Margin  \  |   | | Right  | |    |
  396.         //        |---------+-|           |-+---+-| Bottom |-+----|
  397.         //        |            \ Padding /         \ Left /       |
  398.         // BEGIN -|                                               |
  399.         //        |                /---------\                    |
  400.         //        |               |           |                   |
  401.         //        |               |  / Min \  |    / Width  \     |
  402.         //         \--------------+-|       |-+---|          |---/
  403.         //                           \ Max /       \ Height /
  404.         rautoPx = /^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/;
  405.  
  406. // If this version of jQuery has .swap(), don't false-alarm on internal uses
  407. if ( jQuery.swap ) {
  408.         jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
  409.                 var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
  410.  
  411.                 if ( oldHook ) {
  412.                         jQuery.cssHooks[ name ].get = function() {
  413.                                 var ret;
  414.  
  415.                                 internalSwapCall = true;
  416.                                 ret = oldHook.apply( this, arguments );
  417.                                 internalSwapCall = false;
  418.                                 return ret;
  419.                         };
  420.                 }
  421.         } );
  422. }
  423.  
  424. jQuery.swap = function( elem, options, callback, args ) {
  425.         var ret, name,
  426.                 old = {};
  427.  
  428.         if ( !internalSwapCall ) {
  429.                 migrateWarn( "jQuery.swap() is undocumented and deprecated" );
  430.         }
  431.  
  432.         // Remember the old values, and insert the new ones
  433.         for ( name in options ) {
  434.                 old[ name ] = elem.style[ name ];
  435.                 elem.style[ name ] = options[ name ];
  436.         }
  437.  
  438.         ret = callback.apply( elem, args || [] );
  439.  
  440.         // Revert the old values
  441.         for ( name in options ) {
  442.                 elem.style[ name ] = old[ name ];
  443.         }
  444.  
  445.         return ret;
  446. };
  447.  
  448. if ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) {
  449.  
  450.         jQuery.cssProps = new Proxy( jQuery.cssProps || {}, {
  451.                 set: function() {
  452.                         migrateWarn( "JQMIGRATE: jQuery.cssProps is deprecated" );
  453.                         return Reflect.set.apply( this, arguments );
  454.                 }
  455.         } );
  456. }
  457.  
  458. // Create a dummy jQuery.cssNumber if missing. It won't be used by jQuery but
  459. // it will prevent code adding new keys to it unconditionally from crashing.
  460. if ( !jQuery.cssNumber ) {
  461.         jQuery.cssNumber = {};
  462. }
  463.  
  464. function isAutoPx( prop ) {
  465.  
  466.         // The first test is used to ensure that:
  467.         // 1. The prop starts with a lowercase letter (as we uppercase it for the second regex).
  468.         // 2. The prop is not empty.
  469.         return ralphaStart.test( prop ) &&
  470.                 rautoPx.test( prop[ 0 ].toUpperCase() + prop.slice( 1 ) );
  471. }
  472.  
  473. oldFnCss = jQuery.fn.css;
  474.  
  475. jQuery.fn.css = function( name, value ) {
  476.         var camelName,
  477.                 origThis = this;
  478.         if ( name && typeof name === "object" && !Array.isArray( name ) ) {
  479.                 jQuery.each( name, function( n, v ) {
  480.                         jQuery.fn.css.call( origThis, n, v );
  481.                 } );
  482.                 return this;
  483.         }
  484.         if ( typeof value === "number" ) {
  485.                 camelName = camelCase( name );
  486.                 if ( !isAutoPx( camelName ) && !jQuery.cssNumber[ camelName ] ) {
  487.                         migrateWarn( "Number-typed values are deprecated for jQuery.fn.css( \"" +
  488.                                 name + "\", value )" );
  489.                 }
  490.         }
  491.  
  492.         return oldFnCss.apply( this, arguments );
  493. };
  494.  
  495. var oldData = jQuery.data;
  496.  
  497. jQuery.data = function( elem, name, value ) {
  498.         var curData, sameKeys, key;
  499.  
  500.         // Name can be an object, and each entry in the object is meant to be set as data
  501.         if ( name && typeof name === "object" && arguments.length === 2 ) {
  502.                 curData = jQuery.hasData( elem ) && oldData.call( this, elem );
  503.                 sameKeys = {};
  504.                 for ( key in name ) {
  505.                         if ( key !== camelCase( key ) ) {
  506.                                 migrateWarn( "jQuery.data() always sets/gets camelCased names: " + key );
  507.                                 curData[ key ] = name[ key ];
  508.                         } else {
  509.                                 sameKeys[ key ] = name[ key ];
  510.                         }
  511.                 }
  512.  
  513.                 oldData.call( this, elem, sameKeys );
  514.  
  515.                 return name;
  516.         }
  517.  
  518.         // If the name is transformed, look for the un-transformed name in the data object
  519.         if ( name && typeof name === "string" && name !== camelCase( name ) ) {
  520.                 curData = jQuery.hasData( elem ) && oldData.call( this, elem );
  521.                 if ( curData && name in curData ) {
  522.                         migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name );
  523.                         if ( arguments.length > 2 ) {
  524.                                 curData[ name ] = value;
  525.                         }
  526.                         return curData[ name ];
  527.                 }
  528.         }
  529.  
  530.         return oldData.apply( this, arguments );
  531. };
  532.  
  533. // Support jQuery slim which excludes the effects module
  534. if ( jQuery.fx ) {
  535.  
  536. var intervalValue, intervalMsg,
  537.         oldTweenRun = jQuery.Tween.prototype.run,
  538.         linearEasing = function( pct ) {
  539.                 return pct;
  540.         };
  541.  
  542. jQuery.Tween.prototype.run = function( ) {
  543.         if ( jQuery.easing[ this.easing ].length > 1 ) {
  544.                 migrateWarn(
  545.                         "'jQuery.easing." + this.easing.toString() + "' should use only one argument"
  546.                 );
  547.  
  548.                 jQuery.easing[ this.easing ] = linearEasing;
  549.         }
  550.  
  551.         oldTweenRun.apply( this, arguments );
  552. };
  553.  
  554. intervalValue = jQuery.fx.interval || 13;
  555. intervalMsg = "jQuery.fx.interval is deprecated";
  556.  
  557. // Support: IE9, Android <=4.4
  558. // Avoid false positives on browsers that lack rAF
  559. // Don't warn if document is hidden, jQuery uses setTimeout (#292)
  560. if ( window.requestAnimationFrame ) {
  561.         Object.defineProperty( jQuery.fx, "interval", {
  562.                 configurable: true,
  563.                 enumerable: true,
  564.                 get: function() {
  565.                         if ( !window.document.hidden ) {
  566.                                 migrateWarn( intervalMsg );
  567.                         }
  568.                         return intervalValue;
  569.                 },
  570.                 set: function( newValue ) {
  571.                         migrateWarn( intervalMsg );
  572.                         intervalValue = newValue;
  573.                 }
  574.         } );
  575. }
  576.  
  577. }
  578.  
  579. var oldLoad = jQuery.fn.load,
  580.         oldEventAdd = jQuery.event.add,
  581.         originalFix = jQuery.event.fix;
  582.  
  583. jQuery.event.props = [];
  584. jQuery.event.fixHooks = {};
  585.  
  586. migrateWarnProp( jQuery.event.props, "concat", jQuery.event.props.concat,
  587.         "jQuery.event.props.concat() is deprecated and removed" );
  588.  
  589. jQuery.event.fix = function( originalEvent ) {
  590.         var event,
  591.                 type = originalEvent.type,
  592.                 fixHook = this.fixHooks[ type ],
  593.                 props = jQuery.event.props;
  594.  
  595.         if ( props.length ) {
  596.                 migrateWarn( "jQuery.event.props are deprecated and removed: " + props.join() );
  597.                 while ( props.length ) {
  598.                         jQuery.event.addProp( props.pop() );
  599.                 }
  600.         }
  601.  
  602.         if ( fixHook && !fixHook._migrated_ ) {
  603.                 fixHook._migrated_ = true;
  604.                 migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type );
  605.                 if ( ( props = fixHook.props ) && props.length ) {
  606.                         while ( props.length ) {
  607.                                 jQuery.event.addProp( props.pop() );
  608.                         }
  609.                 }
  610.         }
  611.  
  612.         event = originalFix.call( this, originalEvent );
  613.  
  614.         return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
  615. };
  616.  
  617. jQuery.event.add = function( elem, types ) {
  618.  
  619.         // This misses the multiple-types case but that seems awfully rare
  620.         if ( elem === window && types === "load" && window.document.readyState === "complete" ) {
  621.                 migrateWarn( "jQuery(window).on('load'...) called after load event occurred" );
  622.         }
  623.         return oldEventAdd.apply( this, arguments );
  624. };
  625.  
  626. jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
  627.  
  628.         jQuery.fn[ name ] = function() {
  629.                 var args = Array.prototype.slice.call( arguments, 0 );
  630.  
  631.                 // If this is an ajax load() the first arg should be the string URL;
  632.                 // technically this could also be the "Anything" arg of the event .load()
  633.                 // which just goes to show why this dumb signature has been deprecated!
  634.                 // jQuery custom builds that exclude the Ajax module justifiably die here.
  635.                 if ( name === "load" && typeof args[ 0 ] === "string" ) {
  636.                         return oldLoad.apply( this, args );
  637.                 }
  638.  
  639.                 migrateWarn( "jQuery.fn." + name + "() is deprecated" );
  640.  
  641.                 args.splice( 0, 0, name );
  642.                 if ( arguments.length ) {
  643.                         return this.on.apply( this, args );
  644.                 }
  645.  
  646.                 // Use .triggerHandler here because:
  647.                 // - load and unload events don't need to bubble, only applied to window or image
  648.                 // - error event should not bubble to window, although it does pre-1.7
  649.                 // See http://bugs.jquery.com/ticket/11820
  650.                 this.triggerHandler.apply( this, args );
  651.                 return this;
  652.         };
  653.  
  654. } );
  655.  
  656. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  657.         "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  658.         "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  659.         function( _i, name ) {
  660.  
  661.         // Handle event binding
  662.         jQuery.fn[ name ] = function( data, fn ) {
  663.                 migrateWarn( "jQuery.fn." + name + "() event shorthand is deprecated" );
  664.                 return arguments.length > 0 ?
  665.                         this.on( name, null, data, fn ) :
  666.                         this.trigger( name );
  667.         };
  668. } );
  669.  
  670. // Trigger "ready" event only once, on document ready
  671. jQuery( function() {
  672.         jQuery( window.document ).triggerHandler( "ready" );
  673. } );
  674.  
  675. jQuery.event.special.ready = {
  676.         setup: function() {
  677.                 if ( this === window.document ) {
  678.                         migrateWarn( "'ready' event is deprecated" );
  679.                 }
  680.         }
  681. };
  682.  
  683. jQuery.fn.extend( {
  684.  
  685.         bind: function( types, data, fn ) {
  686.                 migrateWarn( "jQuery.fn.bind() is deprecated" );
  687.                 return this.on( types, null, data, fn );
  688.         },
  689.         unbind: function( types, fn ) {
  690.                 migrateWarn( "jQuery.fn.unbind() is deprecated" );
  691.                 return this.off( types, null, fn );
  692.         },
  693.         delegate: function( selector, types, data, fn ) {
  694.                 migrateWarn( "jQuery.fn.delegate() is deprecated" );
  695.                 return this.on( types, selector, data, fn );
  696.         },
  697.         undelegate: function( selector, types, fn ) {
  698.                 migrateWarn( "jQuery.fn.undelegate() is deprecated" );
  699.                 return arguments.length === 1 ?
  700.                         this.off( selector, "**" ) :
  701.                         this.off( types, selector || "**", fn );
  702.         },
  703.         hover: function( fnOver, fnOut ) {
  704.                 migrateWarn( "jQuery.fn.hover() is deprecated" );
  705.                 return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver );
  706.         }
  707. } );
  708.  
  709. var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  710.         origHtmlPrefilter = jQuery.htmlPrefilter,
  711.         makeMarkup = function( html ) {
  712.                 var doc = window.document.implementation.createHTMLDocument( "" );
  713.                 doc.body.innerHTML = html;
  714.                 return doc.body && doc.body.innerHTML;
  715.         },
  716.         warnIfChanged = function( html ) {
  717.                 var changed = html.replace( rxhtmlTag, "<$1></$2>" );
  718.                 if ( changed !== html && makeMarkup( html ) !== makeMarkup( changed ) ) {
  719.                         migrateWarn( "HTML tags must be properly nested and closed: " + html );
  720.                 }
  721.         };
  722.  
  723. jQuery.UNSAFE_restoreLegacyHtmlPrefilter = function() {
  724.         jQuery.htmlPrefilter = function( html ) {
  725.                 warnIfChanged( html );
  726.                 return html.replace( rxhtmlTag, "<$1></$2>" );
  727.         };
  728. };
  729.  
  730. jQuery.htmlPrefilter = function( html ) {
  731.         warnIfChanged( html );
  732.         return origHtmlPrefilter( html );
  733. };
  734.  
  735. var oldOffset = jQuery.fn.offset;
  736.  
  737. jQuery.fn.offset = function() {
  738.         var elem = this[ 0 ];
  739.  
  740.         if ( elem && ( !elem.nodeType || !elem.getBoundingClientRect ) ) {
  741.                 migrateWarn( "jQuery.fn.offset() requires a valid DOM element" );
  742.                 return arguments.length ? this : undefined;
  743.         }
  744.  
  745.         return oldOffset.apply( this, arguments );
  746. };
  747.  
  748. // Support jQuery slim which excludes the ajax module
  749. // The jQuery.param patch is about respecting `jQuery.ajaxSettings.traditional`
  750. // so it doesn't make sense for the slim build.
  751. if ( jQuery.ajax ) {
  752.  
  753. var oldParam = jQuery.param;
  754.  
  755. jQuery.param = function( data, traditional ) {
  756.         var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
  757.  
  758.         if ( traditional === undefined && ajaxTraditional ) {
  759.  
  760.                 migrateWarn( "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" );
  761.                 traditional = ajaxTraditional;
  762.         }
  763.  
  764.         return oldParam.call( this, data, traditional );
  765. };
  766.  
  767. }
  768.  
  769. var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
  770.  
  771. jQuery.fn.andSelf = function() {
  772.         migrateWarn( "jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()" );
  773.         return oldSelf.apply( this, arguments );
  774. };
  775.  
  776. // Support jQuery slim which excludes the deferred module in jQuery 4.0+
  777. if ( jQuery.Deferred ) {
  778.  
  779. var oldDeferred = jQuery.Deferred,
  780.         tuples = [
  781.  
  782.                 // Action, add listener, callbacks, .then handlers, final state
  783.                 [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  784.                         jQuery.Callbacks( "once memory" ), "resolved" ],
  785.                 [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  786.                         jQuery.Callbacks( "once memory" ), "rejected" ],
  787.                 [ "notify", "progress", jQuery.Callbacks( "memory" ),
  788.                         jQuery.Callbacks( "memory" ) ]
  789.         ];
  790.  
  791. jQuery.Deferred = function( func ) {
  792.         var deferred = oldDeferred(),
  793.                 promise = deferred.promise();
  794.  
  795.         deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
  796.                 var fns = arguments;
  797.  
  798.                 migrateWarn( "deferred.pipe() is deprecated" );
  799.  
  800.                 return jQuery.Deferred( function( newDefer ) {
  801.                         jQuery.each( tuples, function( i, tuple ) {
  802.                                 var fn = typeof fns[ i ] === "function" && fns[ i ];
  803.  
  804.                                 // Deferred.done(function() { bind to newDefer or newDefer.resolve })
  805.                                 // deferred.fail(function() { bind to newDefer or newDefer.reject })
  806.                                 // deferred.progress(function() { bind to newDefer or newDefer.notify })
  807.                                 deferred[ tuple[ 1 ] ]( function() {
  808.                                         var returned = fn && fn.apply( this, arguments );
  809.                                         if ( returned && typeof returned.promise === "function" ) {
  810.                                                 returned.promise()
  811.                                                         .done( newDefer.resolve )
  812.                                                         .fail( newDefer.reject )
  813.                                                         .progress( newDefer.notify );
  814.                                         } else {
  815.                                                 newDefer[ tuple[ 0 ] + "With" ](
  816.                                                         this === promise ? newDefer.promise() : this,
  817.                                                         fn ? [ returned ] : arguments
  818.                                                 );
  819.                                         }
  820.                                 } );
  821.                         } );
  822.                         fns = null;
  823.                 } ).promise();
  824.  
  825.         };
  826.  
  827.         if ( func ) {
  828.                 func.call( deferred, deferred );
  829.         }
  830.  
  831.         return deferred;
  832. };
  833.  
  834. // Preserve handler of uncaught exceptions in promise chains
  835. jQuery.Deferred.exceptionHook = oldDeferred.exceptionHook;
  836.  
  837. }
  838.  
  839. } );

Raw Paste

Login or Register to edit or fork this paste. It's free.