From e6e63f456b45cf6ff6d78aaa4bedafc6db41f88a Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 12 Nov 2019 10:15:16 -0800 Subject: [PATCH] Fixed bubble dispose (#3430) * Fixed bubble dispose. --- core/bubble.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/core/bubble.js b/core/bubble.js index 1e9829e58..883614e77 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -79,6 +79,14 @@ Blockly.Bubble = function(workspace, content, shape, anchorXY, */ this.onMouseDownResizeWrapper_ = null; + /** + * Describes whether this bubble has been disposed of (nodes and event + * listeners removed from the page) or not. + * @type {boolean} + * @package + */ + this.disposed = false; + var angle = Blockly.Bubble.ARROW_ANGLE; if (this.workspace_.RTL) { angle = -angle; @@ -796,24 +804,15 @@ Blockly.Bubble.prototype.setColour = function(hexColour) { * Dispose of this bubble. */ Blockly.Bubble.prototype.dispose = function() { - Blockly.Bubble.unbindDragEvents_(); - // Dispose of and unlink the bubble. - Blockly.utils.dom.removeNode(this.bubbleGroup_); if (this.onMouseDownBubbleWrapper_) { Blockly.unbindEvent_(this.onMouseDownBubbleWrapper_); - this.onMouseDownBubbleWrapper_ = null; } if (this.onMouseDownResizeWrapper_) { Blockly.unbindEvent_(this.onMouseDownResizeWrapper_); - this.onMouseDownResizeWrapper_ = null; } - this.bubbleGroup_ = null; - this.bubbleArrow_ = null; - this.bubbleBack_ = null; - this.resizeGroup_ = null; - this.workspace_ = null; - this.content_ = null; - this.shape_ = null; + Blockly.Bubble.unbindDragEvents_(); + Blockly.utils.dom.removeNode(this.bubbleGroup_); + this.disposed = true; }; /**