Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/234678

Change subject: resourceloader: Remove global startUp() callback
......................................................................

resourceloader: Remove global startUp() callback

Instead of a hardcoded JSONP-style global callback, use script
load handlers. This uses the same logic as jQuery uses internally
(ajax/script.js), which we call inside mediawiki.js. Inline those
two lines here since this the code is what loads jQuery itself.

Bug: T39894
Change-Id: I02b0d16a6ec3081dc551bfd9c3ae652707b7edcf
---
M resources/Resources.php
D resources/src/mediawiki/mediawiki.startUp.js
M resources/src/startup.js
3 files changed, 42 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/78/234678/1

diff --git a/resources/Resources.php b/resources/Resources.php
index 7794911..e21deb9 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -827,7 +827,6 @@
                        'resources/lib/phpjs-sha1/sha1.js',
                        'resources/src/mediawiki/mediawiki.js',
                        'resources/src/mediawiki/mediawiki.errorLogger.js',
-                       'resources/src/mediawiki/mediawiki.startUp.js',
                ),
                'debugScripts' => 'resources/src/mediawiki/mediawiki.log.js',
                'targets' => array( 'desktop', 'mobile' ),
diff --git a/resources/src/mediawiki/mediawiki.startUp.js 
b/resources/src/mediawiki/mediawiki.startUp.js
deleted file mode 100644
index 028784c..0000000
--- a/resources/src/mediawiki/mediawiki.startUp.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/*!
- * Auto-register from pre-loaded startup scripts
- */
-( function ( $ ) {
-       'use strict';
-
-       if ( $.isFunction( window.startUp ) ) {
-               window.startUp();
-               window.startUp = undefined;
-       }
-}( jQuery ) );
diff --git a/resources/src/startup.js b/resources/src/startup.js
index 3b79bd3..c4148fe 100644
--- a/resources/src/startup.js
+++ b/resources/src/startup.js
@@ -68,39 +68,48 @@
        );
 }
 
-/**
- * The $CODE and $VARS placeholders are substituted in 
ResourceLoaderStartUpModule.php.
- */
-function startUp() {
-       mw.config = new mw.Map( $VARS.wgLegacyJavaScriptGlobals );
-
-       $CODE.registrations();
-
-       mw.config.set( $VARS.configuration );
-
-       // Must be after mw.config.set because these callbacks may use 
mw.loader which
-       // needs to have values 'skin', 'debug' etc. from mw.config.
-       window.RLQ = window.RLQ || [];
-       while ( RLQ.length ) {
-               RLQ.shift()();
+// Conditional script injection
+( function () {
+       if ( !isCompatible() ) {
+               // Undo class swapping in case of an unsupported browser.
+               // See OutputPage::getHeadScripts().
+               document.documentElement.className = 
document.documentElement.className
+                       .replace( /(^|\s)client-js(\s|$)/, '$1client-nojs$2' );
        }
-       window.RLQ = {
-               push: function ( fn ) {
-                       fn();
+
+       /**
+        * The $CODE and $VARS placeholders are substituted in 
ResourceLoaderStartUpModule.php.
+        */
+       function startUp() {
+               mw.config = new mw.Map( $VARS.wgLegacyJavaScriptGlobals );
+
+               $CODE.registrations();
+
+               mw.config.set( $VARS.configuration );
+
+               // Must be after mw.config.set because these callbacks may use 
mw.loader which
+               // needs to have values 'skin', 'debug' etc. from mw.config.
+               window.RLQ = window.RLQ || [];
+               while ( RLQ.length ) {
+                       RLQ.shift()();
+               }
+               window.RLQ = {
+                       push: function ( fn ) {
+                               fn();
+                       }
+               };
+       }
+
+       var script = document.createElement( 'script' );
+       script.src = $VARS.baseModulesUri;
+       script.onload = script.onreadystatechange = function() {
+               if ( !script.readyState || /loaded|complete/.test( 
script.readyState ) ) {
+                       // Clean up
+                       script.onload = script.onreadystatechange = null;
+                       script = null;
+                       // Callback
+                       startUp();
                }
        };
-}
-
-// Conditional script injection
-if ( isCompatible() ) {
-       ( function () {
-               var script = document.createElement( 'script' );
-               script.src = $VARS.baseModulesUri;
-               document.getElementsByTagName( 'head' )[0].appendChild( script 
);
-       }() );
-} else {
-       // Undo class swapping in case of an unsupported browser.
-       // See OutputPage::getHeadScripts().
-       document.documentElement.className = document.documentElement.className
-               .replace( /(^|\s)client-js(\s|$)/, '$1client-nojs$2' );
-}
+       document.getElementsByTagName( 'head' )[0].appendChild( script );
+}() );

-- 
To view, visit https://gerrit.wikimedia.org/r/234678
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I02b0d16a6ec3081dc551bfd9c3ae652707b7edcf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to