resourceloader: Make 'script' argument to mw.loader.implement optional
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 21 Jan 2015 00:03:33 +0000 (16:03 -0800)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 21 Jan 2015 00:03:33 +0000 (16:03 -0800)
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

index c7858ab..bed5cb5 100644 (file)
                                        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 ) ) {
                                                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 ) {