From cba7952e3185cc4a6c93617fd8e81be614272f89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 22 Apr 2016 15:32:53 +0200 Subject: [PATCH] HTMLForm: Don't render 'mw-htmlform-submit-buttons' if there aren't any buttons Visually, this only affects OOUIHTMLForm, in other kinds of forms the element has no height anyway. Change-Id: I90e73c49fbefec23532368848bb30b2e7b69075c --- includes/htmlform/HTMLForm.php | 8 +++++--- includes/htmlform/OOUIHTMLForm.php | 8 +++++--- includes/htmlform/VFormHTMLForm.php | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 2b6a0aa4fb..6f88975912 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -1146,10 +1146,12 @@ class HTMLForm extends ContextSource { } } - $html = Html::rawElement( 'span', - [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; + if ( !$buttons ) { + return ''; + } - return $html; + return Html::rawElement( 'span', + [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; } /** diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index 4f8365e019..278d4532aa 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -121,10 +121,12 @@ class OOUIHTMLForm extends HTMLForm { ] + $attrs ); } - $html = Html::rawElement( 'div', - [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; + if ( !$buttons ) { + return ''; + } - return $html; + return Html::rawElement( 'div', + [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; } protected function wrapFieldSetSection( $legend, $section, $attributes ) { diff --git a/includes/htmlform/VFormHTMLForm.php b/includes/htmlform/VFormHTMLForm.php index c4466153a5..f3cba487a2 100644 --- a/includes/htmlform/VFormHTMLForm.php +++ b/includes/htmlform/VFormHTMLForm.php @@ -137,9 +137,11 @@ class VFormHTMLForm extends HTMLForm { $buttons .= Html::element( 'input', $attrs ) . "\n"; } - $html = Html::rawElement( 'div', - [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; + if ( !$buttons ) { + return ''; + } - return $html; + return Html::rawElement( 'div', + [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; } } -- 2.20.1