aboutsummaryrefslogtreecommitdiffstats
path: root/includes/htmlform/HTMLFormField.php
diff options
context:
space:
mode:
authorFomafix <fomafix@googlemail.com>2016-12-27 22:14:16 +0100
committerKrinkle <krinklemail@gmail.com>2018-06-24 01:20:13 +0000
commit125cbd8c017b872c78f047c08f494a458883db23 (patch)
tree4e271c169d5558200f9577e2767403d2ffe9e360 /includes/htmlform/HTMLFormField.php
parent0dead475ab85cbd9c106c8fbaa38779b0c16aaea (diff)
downloadmediawikicore-125cbd8c017b872c78f047c08f494a458883db23.tar.gz
mediawikicore-125cbd8c017b872c78f047c08f494a458883db23.zip
Use \u{00A0} instead of &#160; or &nbsp;
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of the HTML/XML entities &#160; or &#xa0; or &nbsp;. With the UTF-8 character the generated HTML is shorter and better to read. Also change the special value for the label in HTMLForm from &#160; to U+00A0 but also support &#160; for backward compability. Bug: T154300 Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
Diffstat (limited to 'includes/htmlform/HTMLFormField.php')
-rw-r--r--includes/htmlform/HTMLFormField.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php
index a70157572a07..31c72607fcba 100644
--- a/includes/htmlform/HTMLFormField.php
+++ b/includes/htmlform/HTMLFormField.php
@@ -397,9 +397,9 @@ abstract class HTMLFormField {
if ( isset( $params['label-message'] ) ) {
$this->mLabel = $this->getMessage( $params['label-message'] )->parse();
} elseif ( isset( $params['label'] ) ) {
- if ( $params['label'] === '&#160;' ) {
+ if ( $params['label'] === '&#160;' || $params['label'] === "\u{00A0}" ) {
// Apparently some things set &nbsp directly and in an odd format
- $this->mLabel = '&#160;';
+ $this->mLabel = "\u{00A0}";
} else {
$this->mLabel = htmlspecialchars( $params['label'] );
}
@@ -546,7 +546,7 @@ abstract class HTMLFormField {
$horizontalLabel = $this->mParams['horizontal-label'] ?? false;
if ( $horizontalLabel ) {
- $field = '&#160;' . $inputHtml . "\n$errors";
+ $field = "\u{00A0}" . $inputHtml . "\n$errors";
} else {
$field = Html::rawElement(
'div',
@@ -630,7 +630,7 @@ abstract class HTMLFormField {
// the element could specify, that the label doesn't need to be added
$label = $this->getLabel();
- if ( $label && $label !== '&#160;' ) {
+ if ( $label && $label !== "\u{00A0}" ) {
$config['label'] = new OOUI\HtmlSnippet( $label );
}
@@ -745,7 +745,7 @@ abstract class HTMLFormField {
$label = $this->getLabelHtml( $cellAttributes );
$html = "\n" . $errors .
- $label . '&#160;' .
+ $label . "\u{00A0}" .
$inputHtml .
$helptext;
@@ -926,7 +926,13 @@ abstract class HTMLFormField {
* @return string HTML
*/
public function getLabel() {
- return is_null( $this->mLabel ) ? '' : $this->mLabel;
+ if ( is_null( $this->mLabel ) ) {
+ return '';
+ }
+ if ( $this->mLabel === '&#160;' ) {
+ return "\u{00A0}";
+ }
+ return $this->mLabel;
}
public function getLabelHtml( $cellAttributes = [] ) {
@@ -940,7 +946,7 @@ abstract class HTMLFormField {
$labelValue = trim( $this->getLabel() );
$hasLabel = false;
- if ( $labelValue !== '&#160;' && $labelValue !== '' ) {
+ if ( $labelValue !== "\u{00A0}" && $labelValue !== '' ) {
$hasLabel = true;
}