Index: trunk/phase3/includes/resourceloader/ResourceLoader.php |
— | — | @@ -354,6 +354,7 @@ |
355 | 355 | * @return Array |
356 | 356 | */ |
357 | 357 | public function getTestModuleNames( $framework = 'all' ) { |
| 358 | + /// @TODO: api siteinfo prop testmodulenames modulenames |
358 | 359 | if ( $framework == 'all' ) { |
359 | 360 | return $this->testModuleNames; |
360 | 361 | } elseif ( isset( $this->testModuleNames[$framework] ) && is_array( $this->testModuleNames[$framework] ) ) { |
— | — | @@ -797,7 +798,7 @@ |
798 | 799 | * |
799 | 800 | * @param $name string Module name |
800 | 801 | * @param $scripts Mixed: List of URLs to JavaScript files or String of JavaScript code |
801 | | - * @param $styles Mixed: List of CSS strings keyed by media type, or list of lists of URLs to |
| 802 | + * @param $styles Mixed: Array of CSS strings keyed by media type, or an array of lists of URLs to |
802 | 803 | * CSS files keyed by media type |
803 | 804 | * @param $messages Mixed: List of messages associated with this module. May either be an |
804 | 805 | * associative array mapping message key to value, or a JSON-encoded message blob containing |
— | — | @@ -807,7 +808,7 @@ |
808 | 809 | */ |
809 | 810 | public static function makeLoaderImplementScript( $name, $scripts, $styles, $messages ) { |
810 | 811 | if ( is_string( $scripts ) ) { |
811 | | - $scripts = new XmlJsCode( "function( $ ) {{$scripts}}" ); |
| 812 | + $scripts = new XmlJsCode( "function () {\n{$scripts}\n}" ); |
812 | 813 | } elseif ( !is_array( $scripts ) ) { |
813 | 814 | throw new MWException( 'Invalid scripts error. Array of URLs or string of code expected.' ); |
814 | 815 | } |
— | — | @@ -816,6 +817,11 @@ |
817 | 818 | array( |
818 | 819 | $name, |
819 | 820 | $scripts, |
| 821 | + // Force objects. mw.loader.implement requires them to be javascript objects. |
| 822 | + // Although these variables are associative arrays, which become javascript |
| 823 | + // objects through json_encode. In many cases they will be empty arrays, and |
| 824 | + // PHP/json_encode() consider empty arrays to be numerical arrays and |
| 825 | + // output javascript "[]" instead of "{}". This fixes that. |
820 | 826 | (object)$styles, |
821 | 827 | (object)$messages |
822 | 828 | ) ); |
— | — | @@ -901,7 +907,7 @@ |
902 | 908 | public static function makeCustomLoaderScript( $name, $version, $dependencies, $group, $source, $script ) { |
903 | 909 | $script = str_replace( "\n", "\n\t", trim( $script ) ); |
904 | 910 | return Xml::encodeJsCall( |
905 | | - "( function( name, version, dependencies, group, source ) {\n\t$script\n} )", |
| 911 | + "( function ( name, version, dependencies, group, source ) {\n\t$script\n} )", |
906 | 912 | array( $name, $version, $dependencies, $group, $source ) ); |
907 | 913 | } |
908 | 914 | |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -315,7 +315,7 @@ |
316 | 316 | /** |
317 | 317 | * Client-side module loader which integrates with the MediaWiki ResourceLoader |
318 | 318 | */ |
319 | | - loader: ( function() { |
| 319 | + loader: ( function () { |
320 | 320 | |
321 | 321 | /* Private Members */ |
322 | 322 | |
— | — | @@ -756,7 +756,7 @@ |
757 | 757 | registry[module].state = 'loading'; |
758 | 758 | nestedAddScript( script, markModuleReady, registry[module].blocking, 0 ); |
759 | 759 | } else if ( $.isFunction( script ) ) { |
760 | | - script( $ ); |
| 760 | + script(); |
761 | 761 | markModuleReady(); |
762 | 762 | } |
763 | 763 | } catch ( e ) { |
— | — | @@ -1418,7 +1418,7 @@ |
1419 | 1419 | return s; |
1420 | 1420 | } |
1421 | 1421 | }; |
1422 | | - })() |
| 1422 | + }() ) |
1423 | 1423 | }; |
1424 | 1424 | |
1425 | 1425 | })( jQuery ); |