From 75ea8d994151f0639709477aadc345b0a40f13a2 Mon Sep 17 00:00:00 2001 From: John Nesky Date: Mon, 10 Jul 2023 09:18:42 -0700 Subject: [PATCH] fix: disposing workspace comments. (#7264) * fix: disposing workspace comments. * whitespace formatting --- core/workspace_comment_svg.ts | 7 ------- tests/mocha/workspace_comment_test.js | 14 +++++++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/workspace_comment_svg.ts b/core/workspace_comment_svg.ts index 98127cb8e..b8f7547ec 100644 --- a/core/workspace_comment_svg.ts +++ b/core/workspace_comment_svg.ts @@ -144,8 +144,6 @@ export class WorkspaceCommentSvg } dom.removeNode(this.svgGroup); - // Dispose of any rendered components - this.disposeInternal(); eventUtils.disable(); super.dispose(); @@ -989,11 +987,6 @@ export class WorkspaceCommentSvg this.resizeComment(); } - /** Dispose of any rendered comment components. */ - private disposeInternal() { - this.disposed_ = true; - } - /** * Set the focus on the text area. * diff --git a/tests/mocha/workspace_comment_test.js b/tests/mocha/workspace_comment_test.js index e6b15811c..2bd52c616 100644 --- a/tests/mocha/workspace_comment_test.js +++ b/tests/mocha/workspace_comment_test.js @@ -6,7 +6,6 @@ goog.declareModuleId('Blockly.test.workspaceComment'); -import {WorkspaceComment} from '../../build/src/core/workspace_comment.js'; import { sharedTestSetup, sharedTestTeardown, @@ -166,6 +165,19 @@ suite('Workspace comment', function () { // Nothing should go wrong the second time dispose is called. comment.dispose(); }); + + test('WorkspaceCommentSvg disposed', function () { + const comment = new Blockly.WorkspaceCommentSvg( + this.workspace, + 'comment text', + 0, + 0, + 'comment id' + ); + comment.dispose(); + // Nothing should go wrong the second time dispose is called. + comment.dispose(); + }); }); suite('Width and height', function () {