From 9f557f5280063b6e194da4541db75c568d27a901 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Fri, 29 Nov 2019 10:08:15 +0100 Subject: [PATCH] Make Cursor.detach() safe to call when not attached Avoids having checks in higher layers. --- core/util/cursor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/util/cursor.js b/core/util/cursor.js index 35358136..99fe502d 100644 --- a/core/util/cursor.js +++ b/core/util/cursor.js @@ -64,6 +64,10 @@ export default class Cursor { } detach() { + if (!this._target) { + return; + } + if (useFallback) { const options = { capture: true, passive: true }; this._target.removeEventListener('mouseover', this._eventHandlers.mouseover, options);