Skip to content

Commit 4ec9162

Browse files
committed
add type check for flowjs
1 parent 9698f3b commit 4ec9162

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,13 @@ class MarkdownToolbarElement extends HTMLElement {
218218
get field(): ?HTMLTextAreaElement {
219219
const id = this.getAttribute('for')
220220
if (!id) return
221-
const field = this.getRootNode().getElementById(id)
221+
const root = this.getRootNode()
222+
const field =
223+
root instanceof Document
224+
? root.getElementById(id)
225+
: root instanceof DocumentFragment
226+
? root.querySelector(`#${id}`)
227+
: null
222228
return field instanceof HTMLTextAreaElement ? field : null
223229
}
224230
}

0 commit comments

Comments
 (0)