From f496085017d9012709f41b2a28e98c25bb7bf3dd Mon Sep 17 00:00:00 2001 From: Rob Moen Date: Tue, 19 Nov 2013 13:24:44 +0530 Subject: [PATCH] Account for sanitization changes properly in InputWidget setValue() doesn't do anything if this.value === value, but with sanitization it's possible for that to be true while the value in the DOM is out of sync and needs to be changed. The fix is to check for this.value changing and the DOM changing separately. Change-Id: I5f571445f5729f5477902c155a4ee9588b7194a8 --- modules/oojs-ui/widgets/OO.ui.InputWidget.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/oojs-ui/widgets/OO.ui.InputWidget.js b/modules/oojs-ui/widgets/OO.ui.InputWidget.js index 0dc76e65d0..acac9e6839 100644 --- a/modules/oojs-ui/widgets/OO.ui.InputWidget.js +++ b/modules/oojs-ui/widgets/OO.ui.InputWidget.js @@ -114,16 +114,16 @@ OO.ui.InputWidget.prototype.setRTL = function ( isRTL ) { * @chainable */ OO.ui.InputWidget.prototype.setValue = function ( value ) { - var domValue = this.$input.val(); value = this.sanitizeValue( value ); if ( this.value !== value ) { this.value = value; - // Only update the DOM if we must - if ( domValue !== this.value ) { - this.$input.val( value ); - } this.emit( 'change', this.value ); } + // Update the DOM if it has changed. Note that with sanitizeValue, it + // is possible for the DOM value to change without this.value changing. + if ( this.$input.val() !== this.value ) { + this.$input.val( this.value ); + } return this; };