From 757aa8f232753d727491d9d4343625959f3403d1 Mon Sep 17 00:00:00 2001 From: Sam Martin Date: Wed, 6 Mar 2024 16:11:12 -0800 Subject: [PATCH] ensuring we don't affect underlying page when handling noscript --- packages/clarity-js/src/layout/node.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/clarity-js/src/layout/node.ts b/packages/clarity-js/src/layout/node.ts index eedb4816..61b1a3d7 100644 --- a/packages/clarity-js/src/layout/node.ts +++ b/packages/clarity-js/src/layout/node.ts @@ -78,7 +78,7 @@ export default function (node: Node, source: Source): Node { // Also, we do not track text nodes for STYLE tags // The only exception is when we receive a mutation to remove the text node, in that case // parent will be null, but we can still process the node by checking it's an update call. - if (call === "update" || (parent && dom.has(parent) && parent.tagName !== "STYLE")) { + if (call === "update" || (parent && dom.has(parent) && parent.tagName !== "STYLE" && parent.tagName !== "NOSCRIPT")) { let textData = { tag: Constant.TextTag, value: node.nodeValue }; dom[call](node, parent, textData, source); } @@ -108,10 +108,9 @@ export default function (node: Node, source: Source): Node { } break; case "NOSCRIPT": - // keeping the noscript tag but removing all of its contents. Some HTML markup relies on having these tags + // keeping the noscript tag but ignoring its contents. Some HTML markup relies on having these tags // to maintain parity with the original css view, but we don't want to execute any noscript in Clarity - element.innerHTML = ''; - let noscriptData = { tag, attributes: {} }; + let noscriptData = { tag, attributes: {}, value: '' }; dom[call](node, parent, noscriptData, source); break; case "META":