From: Timo Tijhof Date: Thu, 18 Feb 2016 16:33:15 +0000 (+0000) Subject: OutputPage: Minor clean up of and HTML X-Git-Tag: 1.31.0-rc.0~7532^2 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=dd2d7d0ffc08fca741c0541336798196038bdbc3;p=lhc%2Fweb%2Fwiklou.git OutputPage: Minor clean up of 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 --- diff --git a/includes/Html.php b/includes/Html.php index 3b360392d1..890beb0e0d 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -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 { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6949f8b92c..0c3d60929e 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 "" + '' ); } @@ -1396,7 +1396,7 @@ MESSAGE; 'mw.config.set', [ $configuration ], ResourceLoader::inDebugMode() - ) . ResourceLoader::FILTER_NOMIN; + ); } /** diff --git a/includes/resourceloader/ResourceLoaderUserTokensModule.php b/includes/resourceloader/ResourceLoaderUserTokensModule.php index bf4e8a7e21..cea1f3940b 100644 --- a/includes/resourceloader/ResourceLoaderUserTokensModule.php +++ b/includes/resourceloader/ResourceLoaderUserTokensModule.php @@ -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 diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 356eed3f0e..260e0f07f2 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -4773,7 +4773,7 @@ External image !! wikitext External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png !! html -

External image: Ncwikicol.png +

External image: Ncwikicol.png

!! end @@ -4782,7 +4782,7 @@ External image from https !! wikitext External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png !! html -

External image from https: Ncwikicol.png +

External image from https: Ncwikicol.png

!! 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 -

ja-style clickable images: Ncwikicol.png +

ja-style clickable images: Ncwikicol.png

!! html/parsoid

ja-style clickable images: Ncwikicol.png

@@ -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 -

pic.png <-- U+3000 (vim: ^Vu3000) +

pic.png <-- U+3000 (vim: ^Vu3000)

!! end diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index a90295a4c1..98eb0c5718 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -64,7 +64,7 @@ class HtmlTest extends MediaWikiTestCase { $this->setMwGlobals( 'wgWellFormedXml', true ); $this->assertEquals( - '', + '', Html::element( 'img', null, '' ), 'Self-closing tag for short-tag elements (wgWellFormedXml = true)' ); diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index d404ab8ab2..9bef0384d4 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -142,9 +142,9 @@ class OutputPageTest extends MediaWikiTestCase { // Load module script only array( array( 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ), - "" + . "});" ), 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 ), - "" + "" ), // Load private module (combined) array( array( 'test.quux', ResourceLoaderModule::TYPE_COMBINED ), - "" + . "\"]});});" ), // 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 ), - "\n" - . "\n" + . "" + . "});" ), ); // @codingStandardsIgnoreEnd diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index c5314cbacb..7b82d687a4 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -152,7 +152,7 @@ class XmlTest extends MediaWikiTestCase { $this->assertEquals( ' ' . - ' ' . + ' ' . ' ' . ' ' . + ' ' . ' ' . ' ' . + ' ' . ' ' . '