X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderClientHtml.php;h=6061fb518eee5ab7202e9489472ecd0977af4939;hb=efe7286cac744ccc7bce5417d20601a387f6d1ad;hp=84477ca86830b50f1b8c3e6db26f0d3f56684e5f;hpb=962b690e92a258bd53100e976dc5575180696bf0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderClientHtml.php b/includes/resourceloader/ResourceLoaderClientHtml.php index 84477ca868..6061fb518e 100644 --- a/includes/resourceloader/ResourceLoaderClientHtml.php +++ b/includes/resourceloader/ResourceLoaderClientHtml.php @@ -233,27 +233,43 @@ class ResourceLoaderClientHtml { $chunks = []; // Change "client-nojs" class to client-js. This allows easy toggling of UI components. - // This happens synchronously on every page view to avoid flashes of wrong content. + // This must happen synchronously on every page view to avoid flashes of wrong content. // See also #getDocumentAttributes() and /resources/src/startup.js. - $chunks[] = Html::inlineScript( - 'document.documentElement.className = document.documentElement.className' - . '.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );', - $nonce - ); + $script = <<config ) { - $chunks[] = ResourceLoader::makeInlineScript( - ResourceLoader::makeConfigSetScript( $this->config ), - $nonce - ); + $confJson = ResourceLoader::encodeJsonForScript( $this->config ); + $script .= <<exemptStates, $data['states'] ); if ( $states ) { - $chunks[] = ResourceLoader::makeInlineScript( - ResourceLoader::makeLoaderStateScript( $states ), + $stateJson = ResourceLoader::encodeJsonForScript( $states ); + $script .= <<context->getDebug() ) { + $chunks[] = Html::inlineScript( $script, $nonce ); + } else { + $chunks[] = Html::inlineScript( + ResourceLoader::filter( 'minify-js', $script, [ 'cache' => false ] ), $nonce ); } @@ -267,17 +283,6 @@ class ResourceLoaderClientHtml { ); } - // Inline RLQ: Load general modules - if ( $data['general'] ) { - $chunks[] = ResourceLoader::makeInlineScript( - 'RLPAGEMODULES=' - . ResourceLoader::encodeJsonForScript( $data['general'] ) - . ';' - . 'mw.loader.load(RLPAGEMODULES);', - $nonce - ); - } - // External stylesheets (only=styles) if ( $data['styles'] ) { $chunks[] = $this->getLoad( @@ -450,19 +455,17 @@ class ResourceLoaderClientHtml { // Decide whether to use 'style' or 'script' element if ( $only === ResourceLoaderModule::TYPE_STYLES ) { $chunk = Html::linkedStyle( $url ); + } elseif ( $context->getRaw() || $isRaw ) { + $chunk = Html::element( 'script', [ + // In SpecialJavaScriptTest, QUnit must load synchronous + 'async' => !isset( $extraQuery['sync'] ), + 'src' => $url + ] ); } else { - if ( $context->getRaw() || $isRaw ) { - $chunk = Html::element( 'script', [ - // In SpecialJavaScriptTest, QUnit must load synchronous - 'async' => !isset( $extraQuery['sync'] ), - 'src' => $url - ] ); - } else { - $chunk = ResourceLoader::makeInlineScript( - Xml::encodeJsCall( 'mw.loader.load', [ $url ] ), - $nonce - ); - } + $chunk = ResourceLoader::makeInlineScript( + Xml::encodeJsCall( 'mw.loader.load', [ $url ] ), + $nonce + ); } if ( $group == 'noscript' ) {