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

Visual diff: check the rootSelector exists before making the EmbedAPI request #521

Open
humitos opened this issue Feb 4, 2025 · 0 comments
Labels
Improvement Minor improvement to code

Comments

@humitos
Copy link
Member

humitos commented Feb 4, 2025

We perform visual diff over the rootSelector (default or defined by the user) at;

addons/src/docdiff.js

Lines 169 to 172 in 5b70166

const oldBody = htmlDocument.documentElement.querySelector(
this.rootSelector,
);
const newBody = document.querySelector(this.rootSelector);

If the rootSelector is not found in the current page, visual diff won't work. We can take advantage of this and do not perform the EmbedAPI request if we already know it's not gonna work 😄

We will need to check this at

addons/src/docdiff.js

Lines 142 to 147 in 5b70166

promiseData = fetch(url).then((response) => {
if (!response.ok) {
throw new Error("Error downloading requested base URL.");
}
return response.json();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code
Projects
Status: Planned
Development

No branches or pull requests

1 participant