From a18a98235d15b56b19cffb66f7d01611037b66e9 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Thu, 16 May 2024 17:23:41 +0200 Subject: 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 --- includes/Html/Html.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'includes/Html') 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'] ); } } -- cgit v1.2.3