Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/169206
Change subject: ButtonInputWidget: Explicitly disallow setting value when using
<input/>
......................................................................
ButtonInputWidget: Explicitly disallow setting value when using <input/>
There's weird interplay going on when we provide two setters for one
variable, and that's what we accidentally did. PHP and JS behavior
differed subtly, better just check for this explicitly.
Change-Id: I27221a27c00495a50d01144ac88921e83889801e
---
M php/widgets/OoUiButtonInputWidget.php
M src/widgets/ButtonInputWidget.js
2 files changed, 37 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/06/169206/1
diff --git a/php/widgets/OoUiButtonInputWidget.php
b/php/widgets/OoUiButtonInputWidget.php
index 87a3746..e2e622e 100644
--- a/php/widgets/OoUiButtonInputWidget.php
+++ b/php/widgets/OoUiButtonInputWidget.php
@@ -9,9 +9,10 @@
* @param string $config['type'] HTML tag `type` attribute, may be
'button', 'submit' or 'reset'
* (default: 'button')
* @param boolean $config['useInputTag'] Whether to use `<input/>`
rather than `<button/>`. Only
- * useful if you need IE 6 support in a form with multiple buttons.
By using this option, you
- * sacrifice icons and indicators, as well as the ability to have
non-plaintext label or a
- * label different from the value. (default: false)
+ * useful if you need IE 6 support in a form with multiple buttons.
If you use this option,
+ * icons and indicators will not be displayed, it won't be possible
to have a non-plaintext
+ * label, and it won't be possible to set a value (which will
internally become identical to the
+ * label). (default: false)
*/
public function __construct( array $config = array() ) {
// Configuration initialization
@@ -76,4 +77,19 @@
return $this;
}
+
+ /**
+ * Set the value of the input.
+ *
+ * Overridden to disable for `<input/>` elements, which have value
identical to the label.
+ *
+ * @param string $value New value
+ * @chainable
+ */
+ public function setValue( $value ) {
+ if ( !$this->useInputTag ) {
+ parent::setValue( $value );
+ }
+ return $this;
+ }
}
diff --git a/src/widgets/ButtonInputWidget.js b/src/widgets/ButtonInputWidget.js
index b7b0244..af204d8 100644
--- a/src/widgets/ButtonInputWidget.js
+++ b/src/widgets/ButtonInputWidget.js
@@ -22,6 +22,9 @@
// Configuration initialization
config = $.extend( { type: 'button', useInputTag: false }, config );
+ // Properties (must be set before parent constructor, which calls
#setValue)
+ this.useInputTag = config.useInputTag;
+
// Parent constructor
OO.ui.ButtonInputWidget.super.call( this, config );
@@ -32,9 +35,6 @@
OO.ui.LabelElement.call( this, config );
OO.ui.TitledElement.call( this, $.extend( {}, config, { $titled:
this.$input } ) );
OO.ui.FlaggedElement.call( this, config );
-
- // Properties
- this.useInputTag = config.useInputTag;
// Events
this.$input.on( {
@@ -108,6 +108,21 @@
};
/**
+ * Set the value of the input.
+ *
+ * Overridden to disable for `<input/>` elements, which have value identical
to the label.
+ *
+ * @param {string} value New value
+ * @chainable
+ */
+OO.ui.ButtonInputWidget.prototype.setValue = function ( value ) {
+ if ( !this.useInputTag ) {
+ OO.ui.ButtonInputWidget.super.prototype.setValue.call( this,
value );
+ }
+ return this;
+};
+
+/**
* Handles mouse click events.
*
* @param {jQuery.Event} e Mouse click event
--
To view, visit https://gerrit.wikimedia.org/r/169206
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I27221a27c00495a50d01144ac88921e83889801e
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits