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'] );
*/
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)'
);
$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" .
);
$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" .
$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" .
*/
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'
);
*/
public function testTextareaAttribs() {
$this->assertEquals(
- '<textarea name="name" id="name" cols="20" rows="10" class="mw-ui-input"><txt></textarea>',
+ '<textarea name="name" id="name" cols="20" rows="10"><txt></textarea>',
Xml::textarea( 'name', '<txt>', 20, 10 ),
'textarea() with custom attribs'
);