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
parent
fd0d47ad4a
commit
0c7a68bcc1
|
@ -56,14 +56,12 @@ export const removeCursors = (element: HTMLElement) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function: getCurrentStyle
|
|
||||||
*
|
|
||||||
* Returns the current style of the specified element.
|
* Returns the current style of the specified element.
|
||||||
*
|
*
|
||||||
* @param element DOM node whose current style should be returned.
|
* @param element DOM node whose current style should be returned.
|
||||||
*/
|
*/
|
||||||
export const getCurrentStyle = (element: HTMLElement) => {
|
export const getCurrentStyle = (element: HTMLElement) => {
|
||||||
return element ? window.getComputedStyle(element, '') : null;
|
return !element || element.toString() === '[object ShadowRoot]' ? null : window.getComputedStyle(element, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue