diff --git a/includes/Html/Html.php b/includes/Html/Html.php
index 4124d3f618b..98084cc1707 100644
--- a/includes/Html/Html.php
+++ b/includes/Html/Html.php
@@ -152,8 +152,9 @@ class Html {
if ( isset( $attrs['class'] ) ) {
$classAsArray = is_string( $attrs[ 'class' ] ) ? explode( ' ', $attrs[ 'class' ] ) : $attrs[ 'class' ];
if ( !in_array( $cdxInputClass, $classAsArray ) ) {
- $attrs['class'][] = 'mw-ui-input';
+ $classAsArray[] = 'mw-ui-input';
}
+ $attrs['class'] = $classAsArray;
} else {
$attrs['class'] = 'mw-ui-input';
}
diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php
index 7cd65e822db..4fa5d1273fc 100644
--- a/tests/phpunit/includes/HtmlTest.php
+++ b/tests/phpunit/includes/HtmlTest.php
@@ -11,7 +11,6 @@ class HtmlTest extends MediaWikiIntegrationTestCase {
protected function setUp(): void {
parent::setUp();
- $this->overrideConfigValue( MainConfigNames::UseMediaWikiUIEverywhere, false );
$this->overrideConfigValue( MainConfigNames::UsePigLatinVariant, false );
$langFactory = $this->getServiceContainer()->getLanguageFactory();
@@ -831,6 +830,23 @@ class HtmlTest extends MediaWikiIntegrationTestCase {
}
$this->assertSame( $expected, $html );
}
+
+ public function testGetTextInputAttributes() {
+ $this->setMwGlobals( 'wgUseMediaWikiUIEverywhere', true );
+ $attrs = Html::getTextInputAttributes( [ 'class' => 'foo' ] );
+ $attrsNew = Html::getTextInputAttributes( [ 'class' => 'cdx-text-input__input' ] );
+ $attrsArray = Html::getTextInputAttributes( [
+ 'class' => [ 'foo' ]
+ ] );
+ $attrsArrayNew = Html::getTextInputAttributes( [
+ 'class' => [ 'cdx-text-input__input', 'bar' ]
+ ] );
+
+ $this->assertSame( [ 'foo', 'mw-ui-input' ], $attrs[ 'class' ] );
+ $this->assertSame( [ 'cdx-text-input__input' ], $attrsNew[ 'class' ] );
+ $this->assertSame( [ 'foo', 'mw-ui-input' ], $attrsArray[ 'class' ] );
+ $this->assertSame( [ 'cdx-text-input__input', 'bar' ], $attrsArrayNew[ 'class' ] );
+ }
}
class HtmlTestValue {