11/*!
2- * jQuery Migrate - v3.4.0 - 2022-03-24T16:30Z
2+ * jQuery Migrate - v3.4.1 - 2023-02-23T15:31Z
33 * Copyright OpenJS Foundation and other contributors
44 */
55( function ( factory ) {
2424} ) ( function ( jQuery , window ) {
2525"use strict" ;
2626
27- jQuery . migrateVersion = "3.4.0 " ;
27+ jQuery . migrateVersion = "3.4.1 " ;
2828
2929// Returns 0 if v1 == v2, -1 if v1 < v2, 1 if v1 > v2
3030function compareVersions ( v1 , v2 ) {
@@ -91,9 +91,10 @@ jQuery.migrateIsPatchEnabled = function( patchCode ) {
9191 return ;
9292 }
9393
94- // Need jQuery 3.0.0+ and no older Migrate loaded
95- if ( ! jQuery || ! jQueryVersionSince ( "3.0.0" ) ) {
96- window . console . log ( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" ) ;
94+ // Need jQuery 3.x-4.x and no older Migrate loaded
95+ if ( ! jQuery || ! jQueryVersionSince ( "3.0.0" ) ||
96+ jQueryVersionSince ( "5.0.0" ) ) {
97+ window . console . log ( "JQMIGRATE: jQuery 3.x-4.x REQUIRED" ) ;
9798 }
9899 if ( jQuery . migrateWarnings ) {
99100 window . console . log ( "JQMIGRATE: Migrate plugin loaded multiple times" ) ;
@@ -206,9 +207,9 @@ var findProp,
206207 rattrHashTest = / \[ ( \s * [ - \w ] + \s * ) ( [ ~ | ^ $ * ] ? = ) \s * ( [ - \w # ] * ?# [ - \w # ] * ) \s * \] / ,
207208 rattrHashGlob = / \[ ( \s * [ - \w ] + \s * ) ( [ ~ | ^ $ * ] ? = ) \s * ( [ - \w # ] * ?# [ - \w # ] * ) \s * \] / g,
208209
209- // Support: Android <=4.0 only
210- // Make sure we trim BOM and NBSP
211- rtrim = / ^ [ \s \uFEFF \xA0 ] + | [ \s \uFEFF \xA0 ] + $ / g;
210+ // Require that the "whitespace run" starts from a non-whitespace
211+ // to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
212+ rtrim = / ^ [ \s \uFEFF \xA0 ] + | ( [ ^ \s \uFEFF \xA0 ] ) [ \s \uFEFF \xA0 ] + $ / g;
212213
213214migratePatchFunc ( jQuery . fn , "init" , function ( arg1 ) {
214215 var args = Array . prototype . slice . call ( arguments ) ;
@@ -300,7 +301,7 @@ if ( jQueryVersionSince( "3.1.1" ) ) {
300301 migratePatchAndWarnFunc ( jQuery , "trim" , function ( text ) {
301302 return text == null ?
302303 "" :
303- ( text + "" ) . replace ( rtrim , "" ) ;
304+ ( text + "" ) . replace ( rtrim , "$1 " ) ;
304305 } , "trim" ,
305306 "jQuery.trim is deprecated; use String.prototype.trim" ) ;
306307}
@@ -419,10 +420,24 @@ var oldRemoveAttr = jQuery.fn.removeAttr,
419420 rmatchNonSpace = / \S + / g;
420421
421422migratePatchFunc ( jQuery . fn , "removeAttr" , function ( name ) {
422- var self = this ;
423+ var self = this ,
424+ patchNeeded = false ;
423425
424426 jQuery . each ( name . match ( rmatchNonSpace ) , function ( _i , attr ) {
425427 if ( jQuery . expr . match . bool . test ( attr ) ) {
428+
429+ // Only warn if at least a single node had the property set to
430+ // something else than `false`. Otherwise, this Migrate patch
431+ // doesn't influence the behavior and there's no need to set or warn.
432+ self . each ( function ( ) {
433+ if ( jQuery ( this ) . prop ( attr ) !== false ) {
434+ patchNeeded = true ;
435+ return false ;
436+ }
437+ } ) ;
438+ }
439+
440+ if ( patchNeeded ) {
426441 migrateWarn ( "removeAttr-bool" ,
427442 "jQuery.fn.removeAttr no longer sets boolean properties: " + attr ) ;
428443 self . prop ( attr , false ) ;
@@ -470,7 +485,7 @@ function camelCase( string ) {
470485 } ) ;
471486}
472487
473- var origFnCss ,
488+ var origFnCss , internalCssNumber ,
474489 internalSwapCall = false ,
475490 ralphaStart = / ^ [ a - z ] / ,
476491
@@ -552,8 +567,11 @@ if ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) {
552567// https://github.com/jquery/jquery/blob/3.6.0/src/css.js#L212-L233
553568// This way, number values for the CSS properties below won't start triggering
554569// Migrate warnings when jQuery gets updated to >=4.0.0 (gh-438).
555- if ( jQueryVersionSince ( "4.0.0" ) && typeof Proxy !== "undefined" ) {
556- jQuery . cssNumber = new Proxy ( {
570+ if ( jQueryVersionSince ( "4.0.0" ) ) {
571+
572+ // We need to keep this as a local variable as we need it internally
573+ // in a `jQuery.fn.css` patch and this usage shouldn't warn.
574+ internalCssNumber = {
557575 animationIterationCount : true ,
558576 columnCount : true ,
559577 fillOpacity : true ,
@@ -574,16 +592,31 @@ if ( jQueryVersionSince( "4.0.0" ) && typeof Proxy !== "undefined" ) {
574592 widows : true ,
575593 zIndex : true ,
576594 zoom : true
577- } , {
578- get : function ( ) {
579- migrateWarn ( "css-number" , "jQuery.cssNumber is deprecated" ) ;
580- return Reflect . get . apply ( this , arguments ) ;
581- } ,
582- set : function ( ) {
583- migrateWarn ( "css-number" , "jQuery.cssNumber is deprecated" ) ;
584- return Reflect . set . apply ( this , arguments ) ;
585- }
586- } ) ;
595+ } ;
596+
597+ if ( typeof Proxy !== "undefined" ) {
598+ jQuery . cssNumber = new Proxy ( internalCssNumber , {
599+ get : function ( ) {
600+ migrateWarn ( "css-number" , "jQuery.cssNumber is deprecated" ) ;
601+ return Reflect . get . apply ( this , arguments ) ;
602+ } ,
603+ set : function ( ) {
604+ migrateWarn ( "css-number" , "jQuery.cssNumber is deprecated" ) ;
605+ return Reflect . set . apply ( this , arguments ) ;
606+ }
607+ } ) ;
608+ } else {
609+
610+ // Support: IE 9-11+
611+ // IE doesn't support proxies, but we still want to restore the legacy
612+ // jQuery.cssNumber there.
613+ jQuery . cssNumber = internalCssNumber ;
614+ }
615+ } else {
616+
617+ // Make `internalCssNumber` defined for jQuery <4 as well as it's needed
618+ // in the `jQuery.fn.css` patch below.
619+ internalCssNumber = jQuery . cssNumber ;
587620}
588621
589622function isAutoPx ( prop ) {
@@ -610,7 +643,10 @@ migratePatchFunc( jQuery.fn, "css", function( name, value ) {
610643
611644 if ( typeof value === "number" ) {
612645 camelName = camelCase ( name ) ;
613- if ( ! isAutoPx ( camelName ) && ! jQuery . cssNumber [ camelName ] ) {
646+
647+ // Use `internalCssNumber` to avoid triggering our warnings in this
648+ // internal check.
649+ if ( ! isAutoPx ( camelName ) && ! internalCssNumber [ camelName ] ) {
614650 migrateWarn ( "css-number" ,
615651 "Number-typed values are deprecated for jQuery.fn.css( \"" +
616652 name + "\", value )" ) ;
0 commit comments