resourceloader: Remove support for state(name, state) signature
This has no usage in non-test code anywhere in Wikimedia Git, and was only used in the test suite for mw.loader in core, and in the test suite for the NavigationTiming extension. The core usage is as part of this commit. The usage in NavTiming is updated by I240ced4e65988f9. Bug: T127328 Depends-On: I240ced4e65988f96c7ece3772378c2c9a335fb9a Change-Id: Ic17c797e528feaf07a4777709d705615fea353e5
This commit is contained in:
parent
5081fe59e7
commit
6815e35575
4 changed files with 27 additions and 37 deletions
|
|
@ -1298,8 +1298,8 @@ MESSAGE;
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a JS call to mw.loader.state, which sets the state of a
|
||||
* module or modules to a given value. Has two calling conventions:
|
||||
* Returns a JS call to mw.loader.state, which sets the state of one
|
||||
* ore more modules to a given value. Has two calling conventions:
|
||||
*
|
||||
* - ResourceLoader::makeLoaderStateScript( $name, $state ):
|
||||
* Set the state of a single module called $name to $state
|
||||
|
|
@ -1307,24 +1307,19 @@ MESSAGE;
|
|||
* - ResourceLoader::makeLoaderStateScript( [ $name => $state, ... ] ):
|
||||
* Set the state of modules with the given names to the given states
|
||||
*
|
||||
* @param string $name
|
||||
* @param array|string $states
|
||||
* @param string|null $state
|
||||
* @return string JavaScript code
|
||||
*/
|
||||
public static function makeLoaderStateScript( $name, $state = null ) {
|
||||
if ( is_array( $name ) ) {
|
||||
return Xml::encodeJsCall(
|
||||
'mw.loader.state',
|
||||
[ $name ],
|
||||
self::inDebugMode()
|
||||
);
|
||||
} else {
|
||||
return Xml::encodeJsCall(
|
||||
'mw.loader.state',
|
||||
[ $name, $state ],
|
||||
self::inDebugMode()
|
||||
);
|
||||
public static function makeLoaderStateScript( $states, $state = null ) {
|
||||
if ( !is_array( $states ) ) {
|
||||
$states = [ $states => $state ];
|
||||
}
|
||||
return Xml::encodeJsCall(
|
||||
'mw.loader.state',
|
||||
[ $states ],
|
||||
self::inDebugMode()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1922,26 +1922,21 @@
|
|||
/**
|
||||
* Change the state of one or more modules.
|
||||
*
|
||||
* @param {string|Object} module Module name or object of module name/state pairs
|
||||
* @param {string} state State name
|
||||
* @param {Object|string} modules Object of module name/state pairs
|
||||
*/
|
||||
state: function ( module, state ) {
|
||||
var m;
|
||||
|
||||
if ( typeof module === 'object' ) {
|
||||
for ( m in module ) {
|
||||
mw.loader.state( m, module[ m ] );
|
||||
state: function ( modules ) {
|
||||
var module, state;
|
||||
for ( module in modules ) {
|
||||
state = modules[ module ];
|
||||
if ( !hasOwn.call( registry, module ) ) {
|
||||
mw.loader.register( module );
|
||||
}
|
||||
registry[ module ].state = state;
|
||||
if ( state === 'ready' || state === 'error' || state === 'missing' ) {
|
||||
// Make sure pending modules depending on this one get executed if their
|
||||
// dependencies are now fulfilled!
|
||||
handlePending( module );
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( !hasOwn.call( registry, module ) ) {
|
||||
mw.loader.register( module );
|
||||
}
|
||||
registry[ module ].state = state;
|
||||
if ( state === 'ready' || state === 'error' || state === 'missing' ) {
|
||||
// Make sure pending modules depending on this one get executed if their
|
||||
// dependencies are now fulfilled!
|
||||
handlePending( module );
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ if ( isset( $_GET['modules'] ) ) {
|
|||
. '} );';
|
||||
} else {
|
||||
// Default
|
||||
$response .= 'mw.loader.state(' . json_encode( $module ) . ', "missing" );' . "\n";
|
||||
$response .= 'mw.loader.state(' . json_encode( [ $module => 'missing' ] ) . ');' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -665,7 +665,7 @@
|
|||
assert.strictEqual( mw.loader.getState( 'test.module7' ), 'registered', 'Expected "registered" state for test.module7' );
|
||||
assert.strictEqual( mw.loader.getState( 'test.module8' ), 'loaded', 'Expected "loaded" state for test.module8' );
|
||||
assert.strictEqual( mw.loader.getState( 'test.module9' ), 'registered', 'Expected "registered" state for test.module9' );
|
||||
mw.loader.state( 'test.module7', 'missing' );
|
||||
mw.loader.state( { 'test.module7': 'missing' } );
|
||||
assert.strictEqual( mw.loader.getState( 'test.module7' ), 'missing', 'Expected "missing" state for test.module7' );
|
||||
assert.strictEqual( mw.loader.getState( 'test.module8' ), 'error', 'Expected "error" state for test.module8' );
|
||||
assert.strictEqual( mw.loader.getState( 'test.module9' ), 'error', 'Expected "error" state for test.module9' );
|
||||
|
|
@ -732,7 +732,7 @@
|
|||
},
|
||||
function ( e, badmodules ) {
|
||||
assert.ok( true, 'Error handler should be invoked.' );
|
||||
// As soon as server spits out state('testMissing', 'missing');
|
||||
// As soon as server sets state of 'testMissing' to 'missing'
|
||||
// it will bubble up and trigger the error callback.
|
||||
// Therefor the badmodules array is not testUsesMissing or testUsesNestedMissing.
|
||||
assert.deepEqual( badmodules, [ 'testMissing' ], 'Bad modules as expected.' );
|
||||
|
|
|
|||
Loading…
Reference in a new issue