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.
development
Thomas Bouffard 2023-07-06 06:50:51 +02:00 committed by GitHub
parent fd0d47ad4a
commit 0c7a68bcc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -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, '');
};
/**