Skip to content

Commit 925f83f

Browse files
committed
fix: context picker crashes when LinkParser is activated
1 parent eaed61f commit 925f83f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

libs/engine/src/app/components/picker-highlighter.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ const DEFAULT_INACTIVE_BORDER_COLOR = '#384BFF4D' // light blue
77
const DEFAULT_CHILDREN_BORDER_STYLE = 'dashed'
88
const PRIVILEGED_NAMESPACE = 'mweb' // ToDo: hardcode. Needs to be fixed.
99

10-
const getElementDepth = (el: Element | Node) => {
10+
const getElementDepth = (el: Element | ShadowRoot | null | undefined) => {
1111
let depth = 0
12-
let host = (el as any).host
13-
while (el.parentNode !== null || host) {
14-
if (host) el = host as Node
15-
el = el.parentNode!
16-
host = (el as any).host
12+
13+
while (el) {
1714
depth++
15+
el = el instanceof ShadowRoot ? el.host : el.parentElement
1816
}
17+
1918
return depth
2019
}
2120

0 commit comments

Comments
 (0)