From c9d3ae26a9049d03360cb08e086de5cf3012756a Mon Sep 17 00:00:00 2001 From: Utkarsh Chaudhary Date: Fri, 30 Jan 2026 20:44:46 +0530 Subject: [PATCH 1/3] Removing percy attribute before truncate --- lib/core/utils/dq-element.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/utils/dq-element.js b/lib/core/utils/dq-element.js index 373675e3..645b7428 100644 --- a/lib/core/utils/dq-element.js +++ b/lib/core/utils/dq-element.js @@ -174,10 +174,10 @@ function getSource(element) { if (!source && typeof window.XMLSerializer === 'function') { source = new window.XMLSerializer().serializeToString(element); } - let htmlString = truncate(source || ''); // Remove unwanted attributes - const regex = /\s*data-percy-[^=]+="[^"]*"/g; - htmlString = htmlString.replace(regex, ''); + const regex = /\s*data-percy-[^=]+="[^"]*"/g; // Remove unwanted attributes + source = source.replace(regex, ''); + const htmlString = truncate(source || ''); return htmlString; } From 5ccab59164905e81dcebf0a2a356e5f3bd1b7cca Mon Sep 17 00:00:00 2001 From: Utkarsh Chaudhary Date: Mon, 2 Feb 2026 14:45:01 +0530 Subject: [PATCH 2/3] Addressed comments --- lib/core/utils/dq-element.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/utils/dq-element.js b/lib/core/utils/dq-element.js index 645b7428..4e7030cf 100644 --- a/lib/core/utils/dq-element.js +++ b/lib/core/utils/dq-element.js @@ -176,7 +176,7 @@ function getSource(element) { } // Remove unwanted attributes const regex = /\s*data-percy-[^=]+="[^"]*"/g; // Remove unwanted attributes - source = source.replace(regex, ''); + source = (source || '').replace(regex, ''); const htmlString = truncate(source || ''); return htmlString; } From 546df5b706ca3c92dae79f973db4e289af532231 Mon Sep 17 00:00:00 2001 From: Utkarsh Chaudhary Date: Mon, 2 Feb 2026 14:52:00 +0530 Subject: [PATCH 3/3] Addressed comments --- lib/core/utils/dq-element.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/utils/dq-element.js b/lib/core/utils/dq-element.js index 4e7030cf..74b5965d 100644 --- a/lib/core/utils/dq-element.js +++ b/lib/core/utils/dq-element.js @@ -177,7 +177,7 @@ function getSource(element) { // Remove unwanted attributes const regex = /\s*data-percy-[^=]+="[^"]*"/g; // Remove unwanted attributes source = (source || '').replace(regex, ''); - const htmlString = truncate(source || ''); + const htmlString = truncate(source); return htmlString; }