]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Make Cursor.detach() safe to call when not attached
authorPierre Ossman <ossman@cendio.se>
Fri, 29 Nov 2019 09:08:15 +0000 (10:08 +0100)
committerPierre Ossman <ossman@cendio.se>
Fri, 29 Nov 2019 09:08:15 +0000 (10:08 +0100)
Avoids having checks in higher layers.

core/util/cursor.js

index 353581365b5872f059ac735592409f99eeb22f27..99fe502d47ddb4e7e69a8e221f7940ada7500ff3 100644 (file)
@@ -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);