refactor(handles): check if inside a shadow root

This commit is contained in:
moklick
2021-03-29 13:46:41 +02:00
parent c63992e3ff
commit 2eea1c34a1
2 changed files with 24 additions and 9 deletions
+3
View File
@@ -22,3 +22,6 @@ export const clampPosition = (position: XYPosition, extent: NodeExtent) => ({
x: clamp(position.x, extent[0][0], extent[1][0]),
y: clamp(position.y, extent[0][1], extent[1][1]),
});
export const getHostForElement = (element: HTMLElement): Document | ShadowRoot =>
(element.getRootNode?.() as Document | ShadowRoot) || window?.document;