From 5b7dacfd08a3c209ec6f6116eb3ee83d8448ba9b Mon Sep 17 00:00:00 2001 From: yanmao <55792257+yanmao-cc@users.noreply.github.com> Date: Sun, 7 Nov 2021 20:48:43 +0800 Subject: [PATCH] fix(): generate id --- packages/engine/src/node/id.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/engine/src/node/id.ts b/packages/engine/src/node/id.ts index 91c5331b..b776034d 100644 --- a/packages/engine/src/node/id.ts +++ b/packages/engine/src/node/id.ts @@ -68,6 +68,8 @@ class NodeId implements NodeIdInterface { if (isNodeEntry(root) && root.fragment) { root = root.fragment; } + const element = (isNode(root) ? root : root.get()) as Element; + if (element.nodeType === Node.TEXT_NODE) return; const nodes = (isNode(root) ? root : root.get())?.querySelectorAll( tagNames, @@ -88,6 +90,7 @@ class NodeId implements NodeIdInterface { */ generate(node: Node | NodeInterface, force: boolean = false) { if (isNode(node)) node = $(node); + if (node.isText()) return; const rules = this.#rules; // 不符合规则 const nodeRules = rules[node.name];