Skip to content

Commit

Permalink
fix: infinite recursion when shadow root is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Ni55aN committed Aug 13, 2024
1 parent cdf838b commit 142cc5a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export function findSocket(socketsCache: WeakMap<Element, SocketData>, elements:
*/
export function elementsFromPoint(x: number, y: number, root: ShadowRoot | Document = document) {
const elements = root.elementsFromPoint(x, y)
const shadowRoot = elements[0]?.shadowRoot

if (elements[0]?.shadowRoot) {
elements.unshift(...elementsFromPoint(x, y, elements[0].shadowRoot))
if (shadowRoot && shadowRoot !== root) {
elements.unshift(...elementsFromPoint(x, y, shadowRoot))
}

return elements
Expand Down

0 comments on commit 142cc5a

Please sign in to comment.