OutputPage: Minor clean up of <head> and HTML
* Remove trailing space in self-closing tag. Brings parserTest output of Parser and Parsoid closer together. * Remove various line breaks at begin and end of script contents. * Remove FILTER_NOMIN from makeConfigSetScript() output. This isn't part of any user- or page-dependent module and not minified. And Xml::encodeJsCall already ensures compact output for prod mode. Bug: T127328 Change-Id: I85a5a59fd0955c1a112e8b24b933f0d9e983a156
This commit is contained in:
parent
1be3d62f54
commit
dd2d7d0ffc
8 changed files with 33 additions and 34 deletions
|
|
@ -216,7 +216,7 @@ class Html {
|
|||
if ( in_array( $element, self::$voidElements ) ) {
|
||||
if ( $wgWellFormedXml ) {
|
||||
// Silly XML.
|
||||
return substr( $start, 0, -1 ) . ' />';
|
||||
return substr( $start, 0, -1 ) . '/>';
|
||||
}
|
||||
return $start;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ class OutputPage extends ContextSource {
|
|||
* @param string $script Raw HTML
|
||||
*/
|
||||
function addScript( $script ) {
|
||||
$this->mScripts .= $script . "\n";
|
||||
$this->mScripts .= $script;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -516,7 +516,7 @@ class OutputPage extends ContextSource {
|
|||
* @param string $script JavaScript text, no "<script>" tags
|
||||
*/
|
||||
public function addInlineScript( $script ) {
|
||||
$this->mScripts .= Html::inlineScript( "\n$script\n" ) . "\n";
|
||||
$this->mScripts .= Html::inlineScript( $script );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2942,7 +2942,7 @@ class OutputPage extends ContextSource {
|
|||
* @return string HTML fragment
|
||||
*/
|
||||
function getHeadScripts() {
|
||||
return $this->getInlineHeadScripts() . "\n" . $this->getExternalHeadScripts();
|
||||
return $this->getInlineHeadScripts() . $this->getExternalHeadScripts();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -3624,7 +3624,7 @@ class OutputPage extends ContextSource {
|
|||
# If wanted, and the interface is right-to-left, flip the CSS
|
||||
$style_css = CSSJanus::transform( $style_css, true, false );
|
||||
}
|
||||
$this->mInlineStyles .= Html::inlineStyle( $style_css ) . "\n";
|
||||
$this->mInlineStyles .= Html::inlineStyle( $style_css );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -3676,7 +3676,7 @@ class OutputPage extends ContextSource {
|
|||
if ( $this->getLanguage()->getDir() !== $wgContLang->getDir() ) {
|
||||
$previewedCSS = CSSJanus::transform( $previewedCSS, true, false );
|
||||
}
|
||||
$otherTags[] = Html::inlineStyle( $previewedCSS ) . "\n";
|
||||
$otherTags[] = Html::inlineStyle( $previewedCSS );
|
||||
} else {
|
||||
// Load the user styles normally
|
||||
$moduleStyles[] = 'user';
|
||||
|
|
@ -3715,7 +3715,7 @@ class OutputPage extends ContextSource {
|
|||
ResourceLoaderModule::TYPE_STYLES
|
||||
);
|
||||
// Add normal styles added through addStyle()/addInlineStyle() here
|
||||
$links[] = implode( "\n", $this->buildCssLinksArray() ) . $this->mInlineStyles;
|
||||
$links[] = implode( '', $this->buildCssLinksArray() ) . $this->mInlineStyles;
|
||||
// Add marker tag to mark the place where the client-side
|
||||
// loader should inject dynamic styles
|
||||
// We use a <meta> tag with a made-up name for this because that's valid HTML
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class ResourceLoader implements LoggerAwareInterface {
|
|||
private $logger;
|
||||
|
||||
/** @var string JavaScript / CSS pragma to disable minification. **/
|
||||
const FILTER_NOMIN = ' /* @nomin */ ';
|
||||
const FILTER_NOMIN = '/*@nomin*/';
|
||||
|
||||
/**
|
||||
* Load information stored in the database about modules.
|
||||
|
|
@ -1362,8 +1362,8 @@ MESSAGE;
|
|||
* @return string
|
||||
*/
|
||||
public static function makeLoaderConditionalScript( $script ) {
|
||||
return "(window.RLQ = window.RLQ || []).push(function () {\n" .
|
||||
trim( $script ) . "\n} );";
|
||||
return '(window.RLQ=window.RLQ||[]).push(function(){' .
|
||||
trim( $script ) . '});';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1379,8 +1379,8 @@ MESSAGE;
|
|||
$js = self::makeLoaderConditionalScript( $script );
|
||||
return new WrappedString(
|
||||
Html::inlineScript( $js ),
|
||||
"<script>(window.RLQ = window.RLQ || []).push(function () {\n",
|
||||
"\n} );</script>"
|
||||
'<script>(window.RLQ=window.RLQ||[]).push(function(){',
|
||||
'});</script>'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1396,7 +1396,7 @@ MESSAGE;
|
|||
'mw.config.set',
|
||||
[ $configuration ],
|
||||
ResourceLoader::inDebugMode()
|
||||
) . ResourceLoader::FILTER_NOMIN;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule {
|
|||
/**
|
||||
* Generate the JavaScript content of this module.
|
||||
*
|
||||
* Add '@nomin' annotation to prevent the module's contents from getting
|
||||
* cached (T84960).
|
||||
* Add FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
|
||||
*
|
||||
* @param ResourceLoaderContext $context
|
||||
* @return string
|
||||
|
|
|
|||
|
|
@ -4773,7 +4773,7 @@ External image
|
|||
!! wikitext
|
||||
External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
|
||||
!! html
|
||||
<p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
|
||||
<p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
|
||||
</p>
|
||||
!! end
|
||||
|
||||
|
|
@ -4782,7 +4782,7 @@ External image from https
|
|||
!! wikitext
|
||||
External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
|
||||
!! html
|
||||
<p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
|
||||
<p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
|
||||
</p>
|
||||
!! end
|
||||
|
||||
|
|
@ -4856,7 +4856,7 @@ External links: Clickable images
|
|||
!! wikitext
|
||||
ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
|
||||
!! html/php
|
||||
<p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a>
|
||||
<p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/></a>
|
||||
</p>
|
||||
!! html/parsoid
|
||||
<p>ja-style clickable images: <a rel="mw:ExtLink" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p>
|
||||
|
|
@ -20862,7 +20862,7 @@ Bug 19052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
|
|||
!! wikitext
|
||||
http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
|
||||
!! html
|
||||
<p><img src="http://www.example.org/pic.png" alt="pic.png" /> <-- U+3000 (vim: ^Vu3000)
|
||||
<p><img src="http://www.example.org/pic.png" alt="pic.png"/> <-- U+3000 (vim: ^Vu3000)
|
||||
</p>
|
||||
!! end
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class HtmlTest extends MediaWikiTestCase {
|
|||
$this->setMwGlobals( 'wgWellFormedXml', true );
|
||||
|
||||
$this->assertEquals(
|
||||
'<img />',
|
||||
'<img/>',
|
||||
Html::element( 'img', null, '' ),
|
||||
'Self-closing tag for short-tag elements (wgWellFormedXml = true)'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -142,9 +142,9 @@ class OutputPageTest extends MediaWikiTestCase {
|
|||
// Load module script only
|
||||
array(
|
||||
array( 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ),
|
||||
"<script>(window.RLQ = window.RLQ || []).push(function () {\n"
|
||||
"<script>(window.RLQ=window.RLQ||[]).push(function(){"
|
||||
. '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>"
|
||||
. "});</script>"
|
||||
),
|
||||
array(
|
||||
// Don't condition wrap raw modules (like the startup module)
|
||||
|
|
@ -161,17 +161,17 @@ class OutputPageTest extends MediaWikiTestCase {
|
|||
// Load private module (only=scripts)
|
||||
array(
|
||||
array( 'test.quux', ResourceLoaderModule::TYPE_SCRIPTS ),
|
||||
"<script>(window.RLQ = window.RLQ || []).push(function () {\n"
|
||||
. "mw.test.baz({token:123});mw.loader.state({\"test.quux\":\"ready\"});\n"
|
||||
. "} );</script>"
|
||||
"<script>(window.RLQ=window.RLQ||[]).push(function(){"
|
||||
. "mw.test.baz({token:123});mw.loader.state({\"test.quux\":\"ready\"});"
|
||||
. "});</script>"
|
||||
),
|
||||
// Load private module (combined)
|
||||
array(
|
||||
array( 'test.quux', ResourceLoaderModule::TYPE_COMBINED ),
|
||||
"<script>(window.RLQ = window.RLQ || []).push(function () {\n"
|
||||
"<script>(window.RLQ=window.RLQ||[]).push(function(){"
|
||||
. "mw.loader.implement(\"test.quux\",function($,jQuery){"
|
||||
. "mw.test.baz({token:123});},{\"css\":[\".mw-icon{transition:none}"
|
||||
. "\"]});\n} );</script>"
|
||||
. "\"]});});</script>"
|
||||
),
|
||||
// Load no modules
|
||||
array(
|
||||
|
|
@ -186,12 +186,12 @@ class OutputPageTest extends MediaWikiTestCase {
|
|||
// Load two modules in separate groups
|
||||
array(
|
||||
array( array( 'test.group.foo', 'test.group.bar' ), ResourceLoaderModule::TYPE_COMBINED ),
|
||||
"<script>(window.RLQ = window.RLQ || []).push(function () {\n"
|
||||
"<script>(window.RLQ=window.RLQ||[]).push(function(){"
|
||||
. '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 || []).push(function () {\n"
|
||||
. "});</script>\n"
|
||||
. "<script>(window.RLQ=window.RLQ||[]).push(function(){"
|
||||
. 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.foo\u0026skin=fallback");'
|
||||
. "\n} );</script>"
|
||||
. "});</script>"
|
||||
),
|
||||
);
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ class XmlTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertEquals(
|
||||
'<label for="year">From year (and earlier):</label> ' .
|
||||
'<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> ' .
|
||||
'<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
|
||||
'<label for="month">From month (and earlier):</label> ' .
|
||||
'<select name="month" id="month" class="mw-month-selector">' .
|
||||
'<option value="-1">all</option>' . "\n" .
|
||||
|
|
@ -173,7 +173,7 @@ class XmlTest extends MediaWikiTestCase {
|
|||
);
|
||||
$this->assertEquals(
|
||||
'<label for="year">From year (and earlier):</label> ' .
|
||||
'<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> ' .
|
||||
'<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
|
||||
'<label for="month">From month (and earlier):</label> ' .
|
||||
'<select name="month" id="month" class="mw-month-selector">' .
|
||||
'<option value="-1">all</option>' . "\n" .
|
||||
|
|
@ -207,7 +207,7 @@ class XmlTest extends MediaWikiTestCase {
|
|||
|
||||
$this->assertEquals(
|
||||
'<label for="year">From year (and earlier):</label> ' .
|
||||
'<input id="year" maxlength="4" size="7" type="number" name="year" /> ' .
|
||||
'<input id="year" maxlength="4" size="7" type="number" name="year"/> ' .
|
||||
'<label for="month">From month (and earlier):</label> ' .
|
||||
'<select name="month" id="month" class="mw-month-selector">' .
|
||||
'<option value="-1">all</option>' . "\n" .
|
||||
|
|
|
|||
Loading…
Reference in a new issue