jenkins-bot has submitted this change and it was merged. Change subject: Allow whitespace labels ......................................................................
Allow whitespace labels They still must not be empty-string, but this makes it possible to pass " " and have it work the way you might hope. Internally we convert this to " " and set as HTML instead of text because the browser won't respect whitespace. Change-Id: Ie70b21fc13f3ad45b3104d723cbc2d6457c93bad --- M src/elements/OO.ui.LabeledElement.js 1 file changed, 10 insertions(+), 2 deletions(-) Approvals: MarkTraceur: Looks good to me, approved jenkins-bot: Verified diff --git a/src/elements/OO.ui.LabeledElement.js b/src/elements/OO.ui.LabeledElement.js index df3d0e2..b591e2a 100644 --- a/src/elements/OO.ui.LabeledElement.js +++ b/src/elements/OO.ui.LabeledElement.js @@ -41,6 +41,9 @@ /** * Set the label. * + * An empty string will result in the label being hidden. A string containing only whitespace will + * be converted to a single + * * @method * @param {jQuery|string|Function|null} label Label nodes; text; a function that retuns nodes or * text; or null for no label @@ -50,8 +53,13 @@ var empty = false; this.label = label = OO.ui.resolveMsg( label ) || null; - if ( typeof label === 'string' && label.trim() ) { - this.$label.text( label ); + if ( typeof label === 'string' && label.length ) { + if ( label.match( /^\s*$/ ) ) { + // Convert whitespace only string to a single non-breaking space + this.$label.html( ' ' ); + } else { + this.$label.text( label ); + } } else if ( label instanceof jQuery ) { this.$label.empty().append( label ); } else { -- To view, visit https://gerrit.wikimedia.org/r/113386 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie70b21fc13f3ad45b3104d723cbc2d6457c93bad Gerrit-PatchSet: 4 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Trevor Parscal <tpars...@wikimedia.org> Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits