From 0c7a68bcc17684c1266fd8118c2e0e606ba2a8af Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Thu, 6 Jul 2023 06:50:51 +0200 Subject: [PATCH] fix: compute the current style of ShadowRoot element (#214) `ShadowRoot` element cannot be passed to the `window.getComputedStyle` method. Otherwise, errors occur, in particular, it prevents the mouse and gesture events to be propagated. --- packages/core/src/util/styleUtils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/core/src/util/styleUtils.ts b/packages/core/src/util/styleUtils.ts index 8fcb09ef1..faa06ef14 100644 --- a/packages/core/src/util/styleUtils.ts +++ b/packages/core/src/util/styleUtils.ts @@ -56,14 +56,12 @@ export const removeCursors = (element: HTMLElement) => { }; /** - * Function: getCurrentStyle - * * Returns the current style of the specified element. * * @param element DOM node whose current style should be returned. */ export const getCurrentStyle = (element: HTMLElement) => { - return element ? window.getComputedStyle(element, '') : null; + return !element || element.toString() === '[object ShadowRoot]' ? null : window.getComputedStyle(element, ''); }; /**