Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facing issue with skipping difference - preVirtualDiffApply #135

Open
fahdarif opened this issue Dec 7, 2023 · 1 comment
Open

Facing issue with skipping difference - preVirtualDiffApply #135

fahdarif opened this issue Dec 7, 2023 · 1 comment

Comments

@fahdarif
Copy link

fahdarif commented Dec 7, 2023

I am facing an issue while skipping the difference. My use case is that I want to skip all the changes made to BODY element and I am using preVirtualDiffApply with true. It is looping me in infinite circle

Initializing:
window.domDifferenceInstance = new DiffDOM({
preVirtualDiffApply: function (info) {
if (info.node && info.node.nodeName === "BODY") {
console.log("info", info);
// Handle the specific condition for the BODY element
console.log("Here's a special case involving the BODY element");
// Return true only for this specific condition
return true;
}
return false;
},
});

Using function:
export function compareDoms(dom1: HTMLBodyElement | null) {
if (!dom1) {
return;
}
const updatedDOM = document.body.cloneNode(true) as HTMLBodyElement;
const diff = window.domDifferenceInstance.diff(dom1, updatedDOM);
console.log(diff);

const diffJson = JSON.stringify(diff);
return diffJson;
}

@fahdarif fahdarif changed the title Facing issue with skipping differnce Facing issue with skipping difference - preVirtualDiffApply Dec 7, 2023
@johanneswilm
Copy link
Member

Please provide a fully working example on jsdiff or similar so that I can immediately start working on the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants