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

Change subject: Fix checkboxes so the value can actually be set
......................................................................


Fix checkboxes so the value can actually be set

Previously the value was being set with .attr, which doesn't actually
set the value; now setting with .prop.

Also some minor code clean-up.

Change-Id: I7a6ae5a5872a85bee1026ce68d10f3da06bdc8b8
---
M src/widgets/OO.ui.CheckboxInputWidget.js
M src/widgets/OO.ui.CheckboxWidget.js
2 files changed, 9 insertions(+), 11 deletions(-)

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



diff --git a/src/widgets/OO.ui.CheckboxInputWidget.js 
b/src/widgets/OO.ui.CheckboxInputWidget.js
index c2648c3..2c54b04 100644
--- a/src/widgets/OO.ui.CheckboxInputWidget.js
+++ b/src/widgets/OO.ui.CheckboxInputWidget.js
@@ -8,12 +8,8 @@
  * @param {Object} [config] Configuration options
  */
 OO.ui.CheckboxInputWidget = function OoUiCheckboxInputWidget( config ) {
-       config = config || {};
-
        // Parent constructor
        OO.ui.InputWidget.call( this, config );
-
-       this.value = false;
 
        // Initialization
        this.$element.addClass( 'oo-ui-checkboxInputWidget' );
@@ -49,9 +45,10 @@
  * Set value
  */
 OO.ui.CheckboxInputWidget.prototype.setValue = function ( value ) {
+       value = !!value;
        if ( this.value !== value ) {
-               this.value = !!value;
-               this.$element.attr( 'checked', this.value );
+               this.value = value;
+               this.$input.prop( 'checked', this.value );
                this.emit( 'change', this.value );
        }
 };
@@ -63,7 +60,7 @@
        if ( !this.disabled ) {
                // Allow the stack to clear so the value will be updated
                setTimeout( OO.ui.bind( function () {
-                       this.setValue( this.$input.attr( 'checked' ) );
+                       this.setValue( this.$input.prop( 'checked' ) );
                }, this ) );
        }
-};
\ No newline at end of file
+};
diff --git a/src/widgets/OO.ui.CheckboxWidget.js 
b/src/widgets/OO.ui.CheckboxWidget.js
index b642b86..d64c0da 100644
--- a/src/widgets/OO.ui.CheckboxWidget.js
+++ b/src/widgets/OO.ui.CheckboxWidget.js
@@ -10,6 +10,7 @@
  * @cfg {string} [label=''] Label
  */
 OO.ui.CheckboxWidget = function OoUiCheckboxWidget( config ) {
+       // Configuration initialization
        config = config || {};
 
        // Parent constructor
@@ -18,10 +19,10 @@
        // Mixin constructors
        OO.ui.LabeledElement.call( this, this.$( '<span>' ) , config );
 
-       this.$( '<label>' ).append( this.$input, this.$label ).appendTo( 
this.$element );
-
        // Initialization
-       this.$element.addClass( 'oo-ui-checkboxWidget' );
+       this.$element
+               .addClass( 'oo-ui-checkboxWidget' )
+               .append( this.$( '<label>' ).append( this.$input, this.$label ) 
);
 };
 
 /* Inheritance */

-- 
To view, visit https://gerrit.wikimedia.org/r/100414
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7a6ae5a5872a85bee1026ce68d10f3da06bdc8b8
Gerrit-PatchSet: 7
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to