From bd32922ff8f6209bdb20dc0b75c034d1b304dc7a Mon Sep 17 00:00:00 2001 From: Simon Bungartz Date: Wed, 31 Jan 2024 16:16:01 +0000 Subject: [PATCH] Avoid exception when cursor was removed from DOM already --- core/util/cursor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/util/cursor.js b/core/util/cursor.js index 3000cf0e6..20e75f1b2 100644 --- a/core/util/cursor.js +++ b/core/util/cursor.js @@ -69,7 +69,9 @@ export default class Cursor { this._target.removeEventListener('mousemove', this._eventHandlers.mousemove, options); this._target.removeEventListener('mouseup', this._eventHandlers.mouseup, options); - document.body.removeChild(this._canvas); + if (document.contains(this._canvas)) { + document.body.removeChild(this._canvas); + } } this._target = null;