Skip to content

Commit 5376351

Browse files
authored
Pass a root node instead of doc
1 parent 373a08e commit 5376351

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/paste-markdown-html.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ function isChildOfSupportedMarkdownNode({parentNode}: Node): boolean {
136136
}
137137

138138
/** NodeIterator is not iterable, so this wrapper makes it usable in `for...of` loops. */
139-
function* iterateNodes(document: Document, whatToShow?: number, filter?: NodeFilter | null) {
140-
const iterator = document.createNodeIterator(document.body, whatToShow, filter)
139+
function* iterateNodes(root: Node, whatToShow?: number, filter?: NodeFilter | null) {
140+
const iterator = (root.ownerDocument ?? document).createNodeIterator(root, whatToShow, filter)
141141

142142
let node
143143
while ((node = iterator.nextNode())) yield node

0 commit comments

Comments
 (0)