From 7412dde8ee25c5866293b0083cf6b412b44d720a Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 25 Jun 2020 14:37:21 +0200 Subject: [PATCH] Handle quick Cursor detach after mouse up This timer might fire after the Cursor object has detached from a DOM element, causing crashes. This will likely not happen in real scenarios, but the tests are quick enough to trigger this. --- kasmweb/core/util/cursor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kasmweb/core/util/cursor.js b/kasmweb/core/util/cursor.js index c7a084f..d51ff4e 100644 --- a/kasmweb/core/util/cursor.js +++ b/kasmweb/core/util/cursor.js @@ -170,6 +170,10 @@ export default class Cursor { // should be visible. if (this._captureIsActive()) { window.setTimeout(() => { + // We might have detached at this point + if (!this._target) { + return; + } // Refresh the target from elementFromPoint since queued events // might have altered the DOM target = document.elementFromPoint(event.clientX,