From c9bd145768f7be4930ab7e6cc00b397f97f54bee Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Mon, 26 Aug 2019 12:41:08 -0700 Subject: [PATCH] resources: Also add jQuery Migrate to foreign-resources.yaml Change-Id: I218235fa3da0c64f111c7fe2afffeba6a30b6e21 --- resources/lib/foreign-resources.yaml | 14 ++-- resources/lib/jquery/jquery-3.3.1.patch | 11 +-- .../lib/jquery/jquery.migrate-3.0.1.patch | 71 +++++++++++++++++++ 3 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 resources/lib/jquery/jquery.migrate-3.0.1.patch diff --git a/resources/lib/foreign-resources.yaml b/resources/lib/foreign-resources.yaml index 09998dae16..c47a3f402c 100644 --- a/resources/lib/foreign-resources.yaml +++ b/resources/lib/foreign-resources.yaml @@ -115,11 +115,15 @@ html5shiv: integrity: sha384-RPXhaTf22QktT8KTwZ6bUz/C+7CnccaIw5W/y/t0FW5WSDGj3wc3YtRIJC0w47in jquery: - type: file - src: https://code.jquery.com/jquery-3.3.1.js - # Integrity from link modals https://code.jquery.com/jquery/ - integrity: sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60= - dest: jquery.js + type: multi-file + files: + # Integrities from link modals https://code.jquery.com/jquery/ + jquery.migrate.js: + src: https://code.jquery.com/jquery-migrate-3.0.1.js + integrity: sha256-VvnF+Zgpd00LL73P2XULYXEn6ROvoFaa/vbfoiFlZZ4= + jquery.js: + src: https://code.jquery.com/jquery-3.3.1.js + integrity: sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60= jquery.chosen: type: multi-file diff --git a/resources/lib/jquery/jquery-3.3.1.patch b/resources/lib/jquery/jquery-3.3.1.patch index 68a4326d17..06818315f5 100644 --- a/resources/lib/jquery/jquery-3.3.1.patch +++ b/resources/lib/jquery/jquery-3.3.1.patch @@ -1,8 +1,9 @@ ---- jquery-3.3.1.js 2019-04-01 08:39:29.000000000 +0200 -+++ jquery-3.3.1.js 2019-04-01 09:02:39.000000000 +0200 -@@ -260,8 +260,9 @@ jQuery.extend = jQuery.fn.extend = function() { - for ( name in options ) { - src = target[ name ]; +diff --git a/resources/lib/jquery/jquery.js b/resources/lib/jquery/jquery.js +index 9b5206bcc6..34a5703d80 100644 +--- a/resources/lib/jquery/jquery.js ++++ b/resources/lib/jquery/jquery.js +@@ -261,8 +261,9 @@ jQuery.extend = jQuery.fn.extend = function() { + src = target[ name ]; copy = options[ name ]; + // Prevent Object.prototype pollution diff --git a/resources/lib/jquery/jquery.migrate-3.0.1.patch b/resources/lib/jquery/jquery.migrate-3.0.1.patch new file mode 100644 index 0000000000..6036cc9741 --- /dev/null +++ b/resources/lib/jquery/jquery.migrate-3.0.1.patch @@ -0,0 +1,71 @@ +diff --git a/resources/lib/jquery/jquery.migrate.js b/resources/lib/jquery/jquery.migrate.js +index 6ba8af4a42..711e424a39 100644 +--- a/resources/lib/jquery/jquery.migrate.js ++++ b/resources/lib/jquery/jquery.migrate.js +@@ -1,6 +1,14 @@ + /*! + * jQuery Migrate - v3.0.1 - 2017-09-26 + * Copyright jQuery 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. + */ + ;( function( factory ) { + if ( typeof define === "function" && define.amd ) { +@@ -15,7 +23,8 @@ + } else { + + // Browser globals +- factory( jQuery, window ); ++ // PATCH: Qualify jQuery lookup as window.jQuery. --Krinkle ++ factory( window.jQuery, window ); + } + } )( function( jQuery, window ) { + "use strict"; +@@ -58,7 +67,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 +@@ -72,6 +82,10 @@ function migrateWarn( msg ) { + if ( !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" ); ++ } + if ( console && console.warn && !jQuery.migrateMute ) { + console.warn( "JQMIGRATE: " + msg ); + if ( jQuery.migrateTrace && console.trace ) { +@@ -466,20 +480,6 @@ 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 ); +- }; +-} ); +- + // Trigger "ready" event only once, on document ready + jQuery( function() { + jQuery( window.document ).triggerHandler( "ready" ); -- 2.20.1