resourceloader: Make 'script' argument to mw.loader.implement optional

Follows-up 1f393b6.

The others were already made optional (1f393b6), but 'script' was
still required. This caused 4ce0c0da42 to fail since it did sometimes
trim the 'script' argument as well.

Change-Id: I5cf533c2c19a064c4d8686c54838cc7743a09ba5
This commit is contained in:
Timo Tijhof 2015-01-20 16:03:33 -08:00
parent 4ce0c0da42
commit 0e719ce234

View file

@ -1793,7 +1793,7 @@
if ( typeof module !== 'string' ) {
throw new Error( 'module must be of type string, not ' + typeof module );
}
if ( !$.isFunction( script ) && !$.isArray( script ) ) {
if ( script && !$.isFunction( script ) && !$.isArray( script ) ) {
throw new Error( 'script must be of type function or array, not ' + typeof script );
}
if ( style && !$.isPlainObject( style ) ) {
@ -1814,10 +1814,9 @@
throw new Error( 'module already implemented: ' + module );
}
// Attach components
registry[module].script = script;
registry[module].script = script || [];
registry[module].style = style || {};
registry[module].messages = msgs || {};
// Templates are optional (for back-compat)
registry[module].templates = templates || {};
// The module may already have been marked as erroneous
if ( $.inArray( registry[module].state, ['error', 'missing'] ) === -1 ) {