diff options
author | thiemowmde <thiemo.kreuz@wikimedia.de> | 2024-05-16 17:23:41 +0200 |
---|---|---|
committer | thiemowmde <thiemo.kreuz@wikimedia.de> | 2024-05-16 17:24:29 +0200 |
commit | a18a98235d15b56b19cffb66f7d01611037b66e9 (patch) | |
tree | 15930e2888b9291a1296fa7d7702e61cb7a00fd1 /includes/Html | |
parent | a717db8e6088ee2bdc64677d15702bb0ce6fadef (diff) | |
download | mediawikicore-a18a98235d15b56b19cffb66f7d01611037b66e9.tar.gz mediawikicore-a18a98235d15b56b19cffb66f7d01611037b66e9.zip |
Consolidate minor code duplication in Html::dropDefaults
The idea here is that the attribute can be both a value in the array
(with an integer key) or a string key (with a meaningless value,
except for false). This is needed because the normalization via
self::$boolAttribs is done later.
Change-Id: I8c4adab45b84b0cfa607eb1b04944fa2c3a2aa3e
Diffstat (limited to 'includes/Html')
-rw-r--r-- | includes/Html/Html.php | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/includes/Html/Html.php b/includes/Html/Html.php index 8492150e7df9..7b6d6f9df9b2 100644 --- a/includes/Html/Html.php +++ b/includes/Html/Html.php @@ -404,18 +404,11 @@ class Html { } } if ( $element === 'select' && isset( $attribs['size'] ) ) { - if ( in_array( 'multiple', $attribs ) - || ( isset( $attribs['multiple'] ) && $attribs['multiple'] !== false ) - ) { - // A multi-select - if ( strval( $attribs['size'] ) == '4' ) { - unset( $attribs['size'] ); - } - } else { - // Single select - if ( strval( $attribs['size'] ) == '1' ) { - unset( $attribs['size'] ); - } + $multiple = ( $attribs['multiple'] ?? false ) !== false || + in_array( 'multiple', $attribs ); + $default = $multiple ? 4 : 1; + if ( (int)$attribs['size'] === $default ) { + unset( $attribs['size'] ); } } |