From 7ee9b6bc3e8878d727988a2c86070421baa0db33 Mon Sep 17 00:00:00 2001 From: Andrew n marshall Date: Tue, 28 Aug 2018 11:12:30 -0700 Subject: [PATCH] Fix lint errors. --- core/field_textinput.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/core/field_textinput.js b/core/field_textinput.js index e1647ed1f..4815ef54b 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -106,18 +106,17 @@ Blockly.FieldTextInput.prototype.dispose = function() { * @override */ Blockly.FieldTextInput.prototype.setValue = function(newValue) { - if (newValue === null) { - return; // No change if null. - } - if (this.sourceBlock_) { - var validated = this.callValidator(newValue); - // If the new value is invalid, validation returns null. - // In this case we still want to display the illegal result. - if (validated !== null) { - newValue = validated; + if (newValue !== null) { // No change if null. + if (this.sourceBlock_) { + var validated = this.callValidator(newValue); + // If the new value is invalid, validation returns null. + // In this case we still want to display the illegal result. + if (validated !== null) { + newValue = validated; + } } + Blockly.Field.prototype.setValue.call(this, newValue); } - Blockly.Field.prototype.setValue.call(this, newValue); }; /** @@ -369,6 +368,11 @@ Blockly.FieldTextInput.prototype.widgetDispose_ = function() { }; }; +/** + * Attempt to save the text field changes when the user input loses focus. + * If the value is not valid, revert to the default value. + * @private + */ Blockly.FieldTextInput.prototype.maybeSaveEdit_ = function() { var htmlInput = Blockly.FieldTextInput.htmlInput_; // Save the edit (if it validates).