From 8f01155098be883bbbcc453c740a6666f8e5c72d Mon Sep 17 00:00:00 2001 From: Abhishek Bindra Date: Mon, 23 Dec 2024 14:16:20 +0530 Subject: [PATCH] remove unwanted attributes from html string --- lib/core/utils/dq-element.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/core/utils/dq-element.js b/lib/core/utils/dq-element.js index 3cf790fe1..47bcc64e8 100644 --- a/lib/core/utils/dq-element.js +++ b/lib/core/utils/dq-element.js @@ -26,7 +26,11 @@ function getSource(element) { if (!source && typeof window.XMLSerializer === 'function') { source = new window.XMLSerializer().serializeToString(element); } - return truncate(source || ''); + let htmlString = truncate(source || ''); + // Remove unwanted attributes + const regex = /\s*data-percy-[^=]+="[^"]*"/g; + htmlString = htmlString.replace(regex, ''); + return htmlString; } /**