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

Change subject: Account for sanitization changes properly in InputWidget
......................................................................


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
---
M modules/oojs-ui/widgets/OO.ui.InputWidget.js
1 file changed, 5 insertions(+), 5 deletions(-)

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



diff --git a/modules/oojs-ui/widgets/OO.ui.InputWidget.js 
b/modules/oojs-ui/widgets/OO.ui.InputWidget.js
index 0dc76e6..acac9e6 100644
--- a/modules/oojs-ui/widgets/OO.ui.InputWidget.js
+++ b/modules/oojs-ui/widgets/OO.ui.InputWidget.js
@@ -114,16 +114,16 @@
  * @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;
 };
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5f571445f5729f5477902c155a4ee9588b7194a8
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to