mw.log.deprecate( window, '$j', $, 'Use $ or jQuery instead.' );
// Process callbacks for Grade A that require modules.
- // Plain ones were already processed by startup.js.
queue = window.RLQ;
- // Redefine publicly to capture any late arrivals
+ // Replace temporary RLQ implementation from startup.js with the
+ // final implementation that also processes callbacks that can
+ // require modules. It must also support late arrivals of
+ // plain callbacks. (T208093)
window.RLQ = {
push: function ( entry ) {
- mw.loader.using( entry[ 0 ], entry[ 1 ] );
+ if ( typeof entry === 'function' ) {
+ entry();
+ } else {
+ mw.loader.using( entry[ 0 ], entry[ 1 ] );
+ }
}
};
while ( queue[ 0 ] ) {
mw.config.set( $VARS.configuration );
// Process callbacks for Grade A
- // Must be after registrations and mw.config.set, which mw.loader depends on.
var queue = window.RLQ;
- // Redefine push(), but keep type as array for storing callbacks that require modules.
+ // Replace RLQ placeholder from ResourceLoaderClientHtml with an implementation
+ // that executes simple callbacks, but continues to store callbacks that require
+ // modules.
window.RLQ = [];
/* global RLQ */
RLQ.push = function ( fn ) {
}
};
while ( queue && queue[ 0 ] ) {
- // Re-use our push()
+ // Re-use our new push() method
RLQ.push( queue.shift() );
}
QUnit.test( 'RLQ.push', function ( assert ) {
/* global RLQ */
var loaded = 0,
+ called = 0,
done = assert.async();
mw.loader.testCallback = function () {
loaded++;
delete mw.loader.testCallback;
};
- mw.loader.implement( 'test.rlq-push', [ QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/mwLoaderTestCallback.js' ) ] );
+ mw.loader.implement( 'test.rlq-push', [
+ QUnit.fixurl( mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/mwLoaderTestCallback.js' )
+ ] );
+
+ // Regression test for T208093
+ RLQ.push( function () {
+ called++;
+ } );
+ assert.strictEqual( called, 1, 'Invoke plain callbacks' );
RLQ.push( [ 'test.rlq-push', function () {
assert.strictEqual( loaded, 1, 'Load the required module' );