* @return string
*/
public static function makeLoaderConditionalScript( $script ) {
- return "window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n" .
+ return "(window.RLQ = window.RLQ || []).push(function () {\n" .
trim( $script ) . "\n} );";
}
$js = self::makeLoaderConditionalScript( $script );
return new WrappedString(
Html::inlineScript( $js ),
- "<script>window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n",
+ "<script>(window.RLQ = window.RLQ || []).push(function () {\n",
"\n} );</script>"
);
}
// Load module script only
array(
array( 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ),
- "<script>window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n"
+ "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
. 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.foo\u0026only=scripts\u0026skin=fallback");'
. "\n} );</script>"
),
// Load private module (only=scripts)
array(
array( 'test.quux', ResourceLoaderModule::TYPE_SCRIPTS ),
- "<script>window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n"
+ "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
. "mw.test.baz({token:123});mw.loader.state({\"test.quux\":\"ready\"});\n"
. "} );</script>"
),
// Load private module (combined)
array(
array( 'test.quux', ResourceLoaderModule::TYPE_COMBINED ),
- "<script>window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n"
+ "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
. "mw.loader.implement(\"test.quux\",function($,jQuery){"
. "mw.test.baz({token:123});},{\"css\":[\".mw-icon{transition:none}"
. "\"]});\n} );</script>"
// Load two modules in separate groups
array(
array( array( 'test.group.foo', 'test.group.bar' ), ResourceLoaderModule::TYPE_COMBINED ),
- "<script>window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n"
+ "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
. 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.bar\u0026skin=fallback");'
. "\n} );</script>\n"
- . "<script>window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n"
+ . "<script>(window.RLQ = window.RLQ || []).push(function () {\n"
. 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.foo\u0026skin=fallback");'
. "\n} );</script>"
),