Skip to content

Commit 1be13b9

Browse files
authored
remove unwanted attributes from html string (#120)
1 parent 80b022c commit 1be13b9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/core/utils/dq-element.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ function getSource(element) {
2626
if (!source && typeof window.XMLSerializer === 'function') {
2727
source = new window.XMLSerializer().serializeToString(element);
2828
}
29-
return truncate(source || '');
29+
let htmlString = truncate(source || '');
30+
// Remove unwanted attributes
31+
const regex = /\s*data-percy-[^=]+="[^"]*"/g;
32+
htmlString = htmlString.replace(regex, '');
33+
return htmlString;
3034
}
3135

3236
/**

0 commit comments

Comments
 (0)