From 4b1307bb11bc1da9f06f9a7943ccfcef44bb937d Mon Sep 17 00:00:00 2001 From: DD Liu Date: Tue, 11 Jul 2017 11:51:47 -0400 Subject: [PATCH] fix test --- src/engine/target.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/engine/target.js b/src/engine/target.js index 92bd8296..9d135687 100644 --- a/src/engine/target.js +++ b/src/engine/target.js @@ -162,17 +162,21 @@ class Target extends EventEmitter { const variable = this.variables[id]; if (variable.id === id) { variable.name = newName; - const blocks = this.runtime.monitorBlocks; - blocks.changeBlock({ - id: id, - element: 'field', - name: 'VARIABLE', - value: newName - }, this.runtime); - this.runtime.requestUpdateMonitor(Map({ - id: id, - params: blocks._getBlockParams(blocks.getBlock(variable.id)) - })); + + if (this.runtime) { + const blocks = this.runtime.monitorBlocks; + blocks.changeBlock({ + id: id, + element: 'field', + name: 'VARIABLE', + value: newName + }, this.runtime); + this.runtime.requestUpdateMonitor(Map({ + id: id, + params: blocks._getBlockParams(blocks.getBlock(variable.id)) + })); + } + } } } @@ -184,7 +188,9 @@ class Target extends EventEmitter { deleteVariable (id) { if (this.variables.hasOwnProperty(id)) { delete this.variables[id]; - this.runtime.requestRemoveMonitor(id); + if (this.runtime) { + this.runtime.requestRemoveMonitor(id); + } } }