jenkins-bot has submitted this change and it was merged.

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.

Change-Id: I27221a27c00495a50d01144ac88921e83889801e
---
M php/widgets/OoUiButtonInputWidget.php
M src/widgets/ButtonInputWidget.js
2 files changed, 40 insertions(+), 9 deletions(-)

Approvals:
  Trevor Parscal: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/php/widgets/OoUiButtonInputWidget.php 
b/php/widgets/OoUiButtonInputWidget.php
index 87a3746..8d4cc1d 100644
--- a/php/widgets/OoUiButtonInputWidget.php
+++ b/php/widgets/OoUiButtonInputWidget.php
@@ -9,13 +9,17 @@
         * @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
                $config = array_merge( array( 'type' => 'button', 'useInputTag' 
=> false ), $config );
+
+       // Properties (must be set before parent constructor, which calls 
setValue())
+               $this->useInputTag = $config['useInputTag'];
 
                // Parent constructor
                parent::__construct( $config );
@@ -30,9 +34,6 @@
                $this->mixin( new OoUiTitledElement( $this,
                        array_merge( $config, array( 'titled' => $this->input ) 
) ) );
                $this->mixin( new OoUiFlaggedElement( $this, $config ) );
-
-               // Properties
-               $this->useInputTag = $config['useInputTag'];
 
                // Initialization
                if ( !$config['useInputTag'] ) {
@@ -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: merged
Gerrit-Change-Id: I27221a27c00495a50d01144ac88921e83889801e
Gerrit-PatchSet: 3
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to