From 896fdb3d974071a563f31f43eaebb37d7093e76e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 13 Mar 2015 19:49:15 +0100 Subject: [PATCH] Html: Make addition of 'mw-ui-input' conditional on $wgUseMediaWikiUIEverywhere MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We were always adding it previously, which seemed harmless since 'mediawiki.ui.input' RL module, providing the styling, was only loaded if $wgUseMediaWikiUIEverywhere was true… unless someone loaded it manually to have specific input fields styled. Whoops. There are a lot more unconditional additions like this in tons of places in the code, and someone should check whether each one is intentional or not, but probably no one will. Oh well. Bug: T92496 Change-Id: I5e91a3852a76ebbbfe64485bccb4c30ddee28b66 --- includes/Html.php | 17 +++++++++-------- tests/phpunit/includes/HtmlTest.php | 2 +- tests/phpunit/includes/XmlTest.php | 12 ++++++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/includes/Html.php b/includes/Html.php index bc5cde8ef7..879922516e 100644 --- a/includes/Html.php +++ b/includes/Html.php @@ -141,16 +141,17 @@ class Html { if ( !$attrs ) { $attrs = array(); } - if ( isset( $attrs['class'] ) ) { - if ( is_array( $attrs['class'] ) ) { - $attrs['class'][] = 'mw-ui-input'; + if ( $wgUseMediaWikiUIEverywhere ) { + if ( isset( $attrs['class'] ) ) { + if ( is_array( $attrs['class'] ) ) { + $attrs['class'][] = 'mw-ui-input'; + } else { + $attrs['class'] .= ' mw-ui-input'; + } } else { - $attrs['class'] .= ' mw-ui-input'; + $attrs['class'] = 'mw-ui-input'; } - } else { - $attrs['class'] = 'mw-ui-input'; - } - if ( $wgUseMediaWikiUIEverywhere ) { + // Note that size can effect the desired width rendering of mw-ui-input elements // so it is removed. Left intact when mediawiki ui not enabled. unset( $attrs['size'] ); diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 992581b101..0b58536619 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -715,7 +715,7 @@ class HtmlTest extends MediaWikiTestCase { 'Input wrapper with type and value.' ); $this->assertEquals( - '', + '', Html::input( 'testname' ), 'Input wrapper with all default values.' ); diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index e655881975..382e3d89b5 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -81,7 +81,7 @@ class XmlTest extends MediaWikiTestCase { */ public function testElementInputCanHaveAValueOfZero() { $this->assertEquals( - '', + '', Xml::input( 'name', false, 0 ), 'Input with a value of 0 (bug 23797)' ); @@ -152,7 +152,7 @@ class XmlTest extends MediaWikiTestCase { $this->assertEquals( ' ' . - ' ' . + ' ' . ' ' . ' ' . + ' ' . ' ' . ' ' . + ' ' . ' ' . '', + '', Xml::textarea( 'name', '' ), 'textarea() with not content' ); @@ -244,7 +244,7 @@ class XmlTest extends MediaWikiTestCase { */ public function testTextareaAttribs() { $this->assertEquals( - '', + '', Xml::textarea( 'name', '', 20, 10 ), 'textarea() with custom attribs' ); -- 2.20.1