From 36270a00a4d6f5992b555a1353ac3827667c550d Mon Sep 17 00:00:00 2001 From: t7yang Date: Sun, 28 Aug 2022 03:34:53 +0800 Subject: [PATCH] fix: avoid to update node content if the converted content is same as original close Avoid replace text node with same value #39 --- src/content/convert/update-nodes.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/convert/update-nodes.ts b/src/content/convert/update-nodes.ts index 64f4857..1edbd3f 100644 --- a/src/content/convert/update-nodes.ts +++ b/src/content/convert/update-nodes.ts @@ -3,10 +3,10 @@ import { ParsedResult } from 'tongwen-core'; const updateNode = (parsed: ParsedResult, text: string) => { switch (parsed.type) { case 'TEXT': - parsed.node.nodeValue = text; + parsed.node.nodeValue !== text && (parsed.node.nodeValue = text); break; case 'ELEMENT': - parsed.node.setAttribute(parsed.attr, text); + parsed.node.getAttribute(parsed.attr) !== text && parsed.node.setAttribute(parsed.attr, text); } };