Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/core/utils/dq-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,17 @@ function getSourceOpt(element) {
}

function getSource(element) {
if (!element) {
if (!element?.outerHTML) {
return '';
}

// a11y-engine changes - use truncateElement which handles regex replacement
return truncateElement(element);
let source = element.outerHTML;
if (!source && typeof window.XMLSerializer === 'function') {
source = new window.XMLSerializer().serializeToString(element);
}
Comment on lines +288 to +290
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if !source then you will early return from function right? this if check won't be executed anytime

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the original implementation before axe-core upgrade

// a11y-engine changes - use truncate which handles regex replacement
const regex = /\s*data-percy-[^=]+="[^"]*"/g; // Remove unwanted attributes
source = (source || '').replace(regex, '');
return truncate(source);
}

/**
Expand Down
Loading