Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -481,27 +481,30 @@ |
482 | 482 | // Execute script |
483 | 483 | try { |
484 | 484 | var script = registry[module].script; |
| 485 | + var markModuleReady = function() { |
| 486 | + registry[module].state = 'ready'; |
| 487 | + handlePending( module ); |
| 488 | + if ( $.isFunction( callback ) ) { |
| 489 | + callback(); |
| 490 | + } |
| 491 | + }; |
485 | 492 | if ( $.isArray( script ) ) { |
486 | 493 | var done = 0; |
| 494 | + if (script.length == 0 ) { |
| 495 | + // No scripts in this module? Let's dive out early. |
| 496 | + markModuleReady(); |
| 497 | + } |
487 | 498 | for ( var i = 0; i < script.length; i++ ) { |
488 | 499 | registry[module].state = 'loading'; |
489 | 500 | addScript( script[i], function() { |
490 | 501 | if ( ++done == script.length ) { |
491 | | - registry[module].state = 'ready'; |
492 | | - handlePending( module ); |
493 | | - if ( $.isFunction( callback ) ) { |
494 | | - callback(); |
495 | | - } |
| 502 | + markModuleReady(); |
496 | 503 | } |
497 | 504 | } ); |
498 | 505 | } |
499 | 506 | } else if ( $.isFunction( script ) ) { |
500 | 507 | script( jQuery ); |
501 | | - registry[module].state = 'ready'; |
502 | | - handlePending( module ); |
503 | | - if ( $.isFunction( callback ) ) { |
504 | | - callback(); |
505 | | - } |
| 508 | + markModuleReady(); |
506 | 509 | } |
507 | 510 | } catch ( e ) { |
508 | 511 | // This needs to NOT use mw.log because these errors are common in production mode |