diff --git a/resources/lib/jquery/jquery.migrate.js b/resources/lib/jquery/jquery.migrate.js index 7917349ea8..429a66bc12 100644 --- a/resources/lib/jquery/jquery.migrate.js +++ b/resources/lib/jquery/jquery.migrate.js @@ -1,6 +1,16 @@ /*! * jQuery Migrate - v3.3.2 - 2020-11-17T23:22Z * Copyright OpenJS Foundation and other contributors + * + * Patched for MediaWiki: + - Qualify the global lookup for 'jQuery' as 'window.jQuery', + * because within mw.loader.implement() for 'jquery', the closure + * specifies '$' and 'jQuery', which are undefined. + * - Add mw.track instrumentation for statistics. + * - Disable jQuery.migrateTrace by default. They are slow and + * redundant given console.warn() already provides a trace. + * - Don't warn for using features which have no plans for removal. + * - Explicit call to UNSAFE_restoreLegacyHtmlPrefilter() */ ( function( factory ) { "use strict"; @@ -19,7 +29,8 @@ } else { // Browser globals - factory( jQuery, window ); + // PATCH: Qualify jQuery lookup as window.jQuery. --Krinkle + factory( window.jQuery, window ); } } )( function( jQuery, window ) { "use strict"; @@ -82,7 +93,8 @@ jQuery.migrateWarnings = []; // Set to false to disable traces that appear with warnings if ( jQuery.migrateTrace === undefined ) { - jQuery.migrateTrace = true; + // PATCH: Disable extra console.trace() call --Krinkle + jQuery.migrateTrace = false; } // Forget any warnings we've already given; public @@ -96,6 +108,14 @@ function migrateWarn( msg ) { if ( !jQuery.migrateDeduplicateWarnings || !warnedAbout[ msg ] ) { warnedAbout[ msg ] = true; jQuery.migrateWarnings.push( msg ); + // PATCH: Add instrumentation for statistics --Krinkle + if ( window.mw && window.mw.track ) { + window.mw.track( "mw.deprecate", "jquery-migrate" ); + } + + // PATCH: Disable extra console.trace() call --Krinkle + jQuery.migrateTrace = false; + if ( console && console.warn && !jQuery.migrateMute ) { console.warn( "JQMIGRATE: " + msg ); if ( jQuery.migrateTrace && console.trace ) { @@ -672,19 +692,7 @@ jQuery.each( [ "load", "unload", "error" ], function( _, name ) { } ); -jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup contextmenu" ).split( " " ), - function( _i, name ) { - - // Handle event binding - jQuery.fn[ name ] = function( data, fn ) { - migrateWarn( "jQuery.fn." + name + "() event shorthand is deprecated" ); - return arguments.length > 0 ? - this.on( name, null, data, fn ) : - this.trigger( name ); - }; -} ); +// PATCH: Don't warn for using features which have no plans for removal. --Krinkle // Trigger "ready" event only once, on document ready jQuery( function() { @@ -855,5 +863,8 @@ jQuery.Deferred.exceptionHook = oldDeferred.exceptionHook; } +// PATCH: Enable this migration option (disabled by default) to avoid breakage. --JDF/Krinkle +jQuery.UNSAFE_restoreLegacyHtmlPrefilter() + return jQuery; } );