Skip to content

Commit 14c1da8

Browse files
committed
Ensure roots are roots
1 parent 59fbce6 commit 14c1da8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ class MarkdownToolbarElement extends HTMLElement {
298298
get field(): HTMLTextAreaElement | null {
299299
const id = this.getAttribute('for')
300300
if (!id) return null
301-
const field = (this.getRootNode() as Document | ShadowRoot).getElementById(id)
301+
const root = this.getRootNode()
302+
let field
303+
if (root instanceof Document || root instanceof ShadowRoot) {
304+
field = root.getElementById(id)
305+
}
302306
return field instanceof HTMLTextAreaElement ? field : null
303307
}
304308
}

0 commit comments

Comments
 (0)