ResourceLoaderClientHtml: Simplify code
authorFomafix <fomafix@googlemail.com>
Mon, 5 Aug 2019 18:59:08 +0000 (20:59 +0200)
committerFomafix <fomafix@googlemail.com>
Mon, 5 Aug 2019 18:59:08 +0000 (20:59 +0200)
* Use nowdoc instead of heredoc syntax where variable expansion is not
  wanted.
* Combine code paths for debug mode and normal mode.

Change-Id: Ic70d82aaec6396a31783e5a60419409f08c4ef73

includes/resourceloader/ResourceLoaderClientHtml.php

index e324d04..d59e1c8 100644 (file)
@@ -235,7 +235,7 @@ class ResourceLoaderClientHtml {
                // Change "client-nojs" class to client-js. This allows easy toggling of UI components.
                // This must happen synchronously on every page view to avoid flashes of wrong content.
                // See also #getDocumentAttributes() and /resources/src/startup.js.
-               $script = <<<JAVASCRIPT
+               $script = <<<'JAVASCRIPT'
 document.documentElement.className = document.documentElement.className
        .replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );
 JAVASCRIPT;
@@ -265,15 +265,12 @@ RLPAGEMODULES = {$pageModulesJson};
 JAVASCRIPT;
                }
 
-               if ( $this->context->getDebug() ) {
-                       $chunks[] = Html::inlineScript( $script, $nonce );
-               } else {
-                       $chunks[] = Html::inlineScript(
-                               ResourceLoader::filter( 'minify-js', $script, [ 'cache' => false ] ),
-                               $nonce
-                       );
+               if ( !$this->context->getDebug() ) {
+                       $script = ResourceLoader::filter( 'minify-js', $script, [ 'cache' => false ] );
                }
 
+               $chunks[] = Html::inlineScript( $script, $nonce );
+
                // Inline RLQ: Embedded modules
                if ( $data['embed']['general'] ) {
                        $chunks[] = $this->getLoad(