change(tracker): ignore comment nodes

This commit is contained in:
nick-delirium 2023-03-13 09:53:13 +01:00
parent ace7b3ad38
commit 7379b5b9eb
2 changed files with 15 additions and 1 deletions

View file

@ -11,6 +11,10 @@ export function isElementNode(node: Node): node is Element {
return node.nodeType === Node.ELEMENT_NODE
}
export function isCommentNode(node: Node): node is Comment {
return node.nodeType === Node.COMMENT_NODE
}
export function isTextNode(node: Node): node is Text {
return node.nodeType === Node.TEXT_NODE
}

View file

@ -10,9 +10,19 @@ import {
RemoveNode,
} from '../messages.gen.js'
import App from '../index.js'
import { isRootNode, isTextNode, isElementNode, isSVGElement, hasTag } from '../guards.js'
import {
isRootNode,
isTextNode,
isElementNode,
isSVGElement,
hasTag,
isCommentNode,
} from '../guards.js'
function isIgnored(node: Node): boolean {
if (isCommentNode(node)) {
return true
}
if (isTextNode(node)) {
return false
}