From 7f160bd322a5a17fddceaeaf73d052165e614f30 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 10 Jan 2019 14:35:06 -0800 Subject: [PATCH] Fixed comments not being recorded in delete event. (#2211) --- core/block_svg.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/block_svg.js b/core/block_svg.js index 37ef35803..7a2c7dfa5 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -893,16 +893,28 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) { this.warningTextDb_ = null; } + // If the block is rendered we need to record the event before disposing of + // the icons to prevent losing information. + // TODO (#1969): Remove event generation/firing once comments are fixed. + this.unplug(healStack); + var deleteEvent; + if (Blockly.Events.isEnabled()) { + deleteEvent = new Blockly.Events.BlockDelete(this); + } Blockly.Events.disable(); try { var icons = this.getIcons(); for (var i = 0; i < icons.length; i++) { icons[i].dispose(); } + // TODO (#1969): Move out of disable block once comments are fixed. + Blockly.BlockSvg.superClass_.dispose.call(this, healStack); } finally { Blockly.Events.enable(); } - Blockly.BlockSvg.superClass_.dispose.call(this, healStack); + if (Blockly.Events.isEnabled() && deleteEvent) { + Blockly.Events.fire(deleteEvent); + } Blockly.utils.removeNode(this.svgGroup_); blockWorkspace.resizeContents();