Skip to content

Commit 6299b57

Browse files
committed
add el.ownerDocument check, add comments
1 parent 240567b commit 6299b57

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

web_src/js/utils/dom.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ export function onDomReady(cb) {
5959
}
6060
}
6161

62+
// checks whether an element is owned by the current document, and whether it is a document fragment or element node
63+
// if it is, it means it is a "normal" element managed by us, which can be modified safely.
6264
export function isDocumentFragmentOrElementNode(el) {
6365
try {
64-
return el.nodeType === Node.ELEMENT_NODE || el.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
66+
return el.ownerDocument === document && el.nodeType === Node.ELEMENT_NODE || el.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
6567
} catch {
6668
// in case the el is not in the same origin, then the access to nodeType would fail
6769
return false;

0 commit comments

Comments
 (0)