resources: Also add jQuery Migrate to foreign-resources.yaml
authorJames D. Forrester <jforrester@wikimedia.org>
Mon, 26 Aug 2019 19:41:08 +0000 (12:41 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Mon, 26 Aug 2019 19:54:46 +0000 (12:54 -0700)
Change-Id: I218235fa3da0c64f111c7fe2afffeba6a30b6e21

resources/lib/foreign-resources.yaml
resources/lib/jquery/jquery-3.3.1.patch
resources/lib/jquery/jquery.migrate-3.0.1.patch [new file with mode: 0644]

index 09998da..c47a3f4 100644 (file)
@@ -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
index 68a4326..0681831 100644 (file)
@@ -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 (file)
index 0000000..6036cc9
--- /dev/null
@@ -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" );