From 0e719ce234c7251b47707b8415be5a2fddbdecec Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 20 Jan 2015 16:03:33 -0800 Subject: [PATCH] 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 --- resources/src/mediawiki/mediawiki.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index c7858ab62c..bed5cb5b63 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -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 ) { -- 2.20.1