$out .= self::makeLoaderStateScript( $states );
}
- // In only=script requests for modules that are not raw (e.g. not the startup module)
- // ensure the execution is conditional to avoid situations where browsers with an
- // unsupported environment do unconditionally execute a module's scripts. Otherwise users
- // will get things like "ReferenceError: mw is undefined" or "jQuery is undefined" from
- // legacy scripts loaded with only=scripts (such as the 'site' module).
- $out = self::makeLoaderConditionalScript( $out );
+ if ( $context->getOnly() === 'scripts' ) {
+ // In only=script requests for modules that are not raw (e.g. not the startup module)
+ // ensure the execution is conditional to avoid situations where browsers with an
+ // unsupported environment do unconditionally execute a module's scripts. Otherwise users
+ // will get things like "ReferenceError: mw is undefined" or "jQuery is undefined" from
+ // legacy scripts loaded with only=scripts (such as the 'site' module).
+ $out = self::makeLoaderConditionalScript( $out );
+ }
} else {
if ( count( $states ) ) {
$exceptions .= self::makeComment(
array(
array( array( 'test.baz', 'test.foo', 'test.bar' ), ResourceLoaderModule::TYPE_STYLES ),
'<link rel=stylesheet href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.bar%2Cbaz%2Cfoo&only=styles&skin=fallback&*">
+'
+ ),
+ // Load private module (scripts)
+ array(
+ array( 'test.quux', ResourceLoaderModule::TYPE_SCRIPTS ),
+ '<script>if(window.mw){mw.test.baz({token:123});mw.loader.state({"test.quux":"ready"});}
+</script>
'
),
// Load private module (combined)
array(
array( 'test.quux', ResourceLoaderModule::TYPE_COMBINED ),
- '<script>if(window.mw){mw.loader.implement("test.quux",function($,jQuery){mw.test.baz({token:123});},{"css":[".mw-icon{transition:none}\n"]},{});}
+ '<script>mw.loader.implement("test.quux",function($,jQuery){mw.test.baz({token:123});},{"css":[".mw-icon{transition:none}\n"]},{});
</script>
'
),