From 586f1fd94cad2967b2b4144877da8f84831ead7c Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 19 Dec 2024 12:00:52 +0100 Subject: [PATCH] Removed as, fixed types in isElementInToolbar --- src/heatmaps.ts | 2 +- src/utils/element-utils.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/heatmaps.ts b/src/heatmaps.ts index e1e69a270..8948fe0ab 100644 --- a/src/heatmaps.ts +++ b/src/heatmaps.ts @@ -177,7 +177,7 @@ export class Heatmaps { } private _onMouseMove(e: Event): void { - if (isElementInToolbar(e.target as Element)) { + if (isElementInToolbar(e.target)) { return } clearTimeout(this._mouseMoveTimeout) diff --git a/src/utils/element-utils.ts b/src/utils/element-utils.ts index 664248328..f784ff8aa 100644 --- a/src/utils/element-utils.ts +++ b/src/utils/element-utils.ts @@ -1,8 +1,11 @@ import { TOOLBAR_CONTAINER_CLASS, TOOLBAR_ID } from '../constants' -export function isElementInToolbar(el: Element | null): boolean { - // NOTE: .closest is not supported in IE11 hence the operator check - return el?.id === TOOLBAR_ID || !!el?.closest?.('.' + TOOLBAR_CONTAINER_CLASS) +export function isElementInToolbar(el: EventTarget | null): boolean { + if (el instanceof Element) { + // NOTE: .closest is not supported in IE11 hence the operator check + return el.id === TOOLBAR_ID || !!el.closest?.('.' + TOOLBAR_CONTAINER_CLASS) + } + return false } /*