jquery-migrate.js 25 KB

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