);
$context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) );
- // Extract modules that know they're empty
+
+ // Extract modules that know they're empty and see if we have one or more
+ // raw modules
+ $isRaw = false;
foreach ( $grpModules as $key => $module ) {
// Inline empty modules: since they're empty, just mark them as 'ready' (bug 46857)
// If we're only getting the styles, we don't need to do anything for empty modules.
$links['states'][$key] = 'ready';
}
}
+
+ $isRaw |= $module->isRaw();
}
// If there are no non-empty modules, skip this group
);
} else {
$links['html'] .= Html::inlineScript(
- $resourceLoader->makeModuleResponse( $context, $grpModules )
+ ResourceLoader::makeLoaderConditionalScript(
+ $resourceLoader->makeModuleResponse( $context, $grpModules )
+ )
);
}
$links['html'] .= "\n";
);
} else {
$link = Html::linkedScript( $url );
+ if ( $context->getOnly() === 'scripts' && !$context->getRaw() && !$isRaw ) {
+ // Wrap only=script requests in a conditional as browsers not supported
+ // by the startup module would unconditionally execute this module.
+ // Otherwise users will get "ReferenceError: mw is undefined" or
+ // "jQuery is undefined" from e.g. a "site" module.
+ $link = Html::inlineScript(
+ ResourceLoader::makeLoaderConditionalScript(
+ Xml::encodeJsCall( 'document.write', array( $link ) )
+ )
+ );
+ }
// For modules requested directly in the html via <link> or <script>,
// tell mw.loader they are being loading to prevent duplicate requests.
if ( $flip === 'flip' && $this->getLanguage()->isRTL() ) {
# If wanted, and the interface is right-to-left, flip the CSS
$style_css = CSSJanus::transform( $style_css, true, false );
+ } else {
+ $style_css = CSSJanus::nullTransform( $style_css );
}
$this->mInlineStyles .= Html::inlineStyle( $style_css ) . "\n";
}
$previewedCSS = $this->getRequest()->getText( 'wpTextbox1' );
if ( $this->getLanguage()->getDir() !== $wgContLang->getDir() ) {
$previewedCSS = CSSJanus::transform( $previewedCSS, true, false );
+ } else {
+ $previewedCSS = CSSJanus::nullTransform( $previewedCSS );
}
$otherTags .= Html::inlineStyle( $previewedCSS ) . "\n";
} else {