jenkins-bot has submitted this change and it was merged.

Change subject: Html: Make addition of 'mw-ui-input' conditional on 
$wgUseMediaWikiUIEverywhere
......................................................................


Html: Make addition of 'mw-ui-input' conditional on $wgUseMediaWikiUIEverywhere

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
---
M includes/Html.php
M tests/phpunit/includes/HtmlTest.php
M tests/phpunit/includes/XmlTest.php
3 files changed, 17 insertions(+), 16 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Html.php b/includes/Html.php
index bc5cde8..8799225 100644
--- a/includes/Html.php
+++ b/includes/Html.php
@@ -141,16 +141,17 @@
                if ( !$attrs ) {
                        $attrs = array();
                }
-               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';
-               }
                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';
+                       }
+
                        // 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 992581b..0b58536 100644
--- a/tests/phpunit/includes/HtmlTest.php
+++ b/tests/phpunit/includes/HtmlTest.php
@@ -715,7 +715,7 @@
                        'Input wrapper with type and value.'
                );
                $this->assertEquals(
-                       '<input name=testname class=mw-ui-input>',
+                       '<input name=testname>',
                        Html::input( 'testname' ),
                        'Input wrapper with all default values.'
                );
diff --git a/tests/phpunit/includes/XmlTest.php 
b/tests/phpunit/includes/XmlTest.php
index e655881..382e3d8 100644
--- a/tests/phpunit/includes/XmlTest.php
+++ b/tests/phpunit/includes/XmlTest.php
@@ -81,7 +81,7 @@
         */
        public function testElementInputCanHaveAValueOfZero() {
                $this->assertEquals(
-                       '<input name="name" value="0" class="mw-ui-input" />',
+                       '<input name="name" value="0" />',
                        Xml::input( 'name', false, 0 ),
                        'Input with a value of 0 (bug 23797)'
                );
@@ -152,7 +152,7 @@
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" 
type="number" value="2011" name="year" class="mw-ui-input" /> ' .
+                               '<input id="year" maxlength="4" size="7" 
type="number" value="2011" name="year" /> ' .
                                '<label for="month">From month (and 
earlier):</label> ' .
                                '<select id="month" name="month" 
class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
@@ -173,7 +173,7 @@
                );
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" 
type="number" value="2011" name="year" class="mw-ui-input" /> ' .
+                               '<input id="year" maxlength="4" size="7" 
type="number" value="2011" name="year" /> ' .
                                '<label for="month">From month (and 
earlier):</label> ' .
                                '<select id="month" name="month" 
class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
@@ -207,7 +207,7 @@
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" 
type="number" name="year" class="mw-ui-input" /> ' .
+                               '<input id="year" maxlength="4" size="7" 
type="number" name="year" /> ' .
                                '<label for="month">From month (and 
earlier):</label> ' .
                                '<select id="month" name="month" 
class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
@@ -233,7 +233,7 @@
         */
        public function testTextareaNoContent() {
                $this->assertEquals(
-                       '<textarea name="name" id="name" cols="40" rows="5" 
class="mw-ui-input"></textarea>',
+                       '<textarea name="name" id="name" cols="40" 
rows="5"></textarea>',
                        Xml::textarea( 'name', '' ),
                        'textarea() with not content'
                );
@@ -244,7 +244,7 @@
         */
        public function testTextareaAttribs() {
                $this->assertEquals(
-                       '<textarea name="name" id="name" cols="20" rows="10" 
class="mw-ui-input">&lt;txt&gt;</textarea>',
+                       '<textarea name="name" id="name" cols="20" 
rows="10">&lt;txt&gt;</textarea>',
                        Xml::textarea( 'name', '<txt>', 20, 10 ),
                        'textarea() with custom attribs'
                );

-- 
To view, visit https://gerrit.wikimedia.org/r/196623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5e91a3852a76ebbbfe64485bccb4c30ddee28b66
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Daniel Friesen <dan...@nadir-seen-fire.com>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to