From: Timo Tijhof Date: Wed, 21 Jan 2015 00:03:33 +0000 (-0800) Subject: resourceloader: Make 'script' argument to mw.loader.implement optional X-Git-Tag: 1.31.0-rc.0~12608^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=0e719ce234c7251b47707b8415be5a2fddbdecec;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ) {