Skip to content

Commit

Permalink
style: simplify the node type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
cycleccc committed Oct 28, 2024
1 parent 296580f commit af62f69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@ export function walkTextNodes(
const node = nodes[i]
const nodeType = node.nodeType

if (nodeType === NodeType.TEXT_NODE) {
if (isDOMText(node)) {
// 匹配到 text node ,执行函数
handler(node, elem)
} else if (nodeType === NodeType.ELEMENT_NODE || nodeType === NodeType.DOCUMENT_NODE || nodeType === NodeType.DOCUMENT_FRAGMENT_NODE) {
} else if ([NodeType.ELEMENT_NODE, NodeType.DOCUMENT_NODE, NodeType.DOCUMENT_FRAGMENT_NODE].includes(nodeType)) {
// 继续遍历子节点
walkTextNodes(node as DOMElement, handler)
}
Expand Down

0 comments on commit af62f69

Please sign in to comment.