From 528ea86cbf587f8871282a28bd6f637772d69f1c Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 3 Jan 2017 14:58:05 -0800 Subject: [PATCH] Check if the text has changed before firing an event --- core/field_textinput.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/field_textinput.js b/core/field_textinput.js index 3d224c031..5c6e66215 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -99,6 +99,15 @@ Blockly.FieldTextInput.prototype.setValue = function(newValue) { * @param {*} newText New text. */ Blockly.FieldTextInput.prototype.setText = function(newText) { + if (newText === null) { + // No change if null. + return; + } + newText = String(newText); + if (newText === this.text_) { + // No change. + return; + } if (this.sourceBlock_ && Blockly.Events.isEnabled()) { Blockly.Events.fire(new Blockly.Events.Change( this.sourceBlock_, 'field', this.name, this.text_, newText));