Skip to content

Visual diff is not working on mkdocs, double-selects root element #12134

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

Open
reteps opened this issue Apr 26, 2025 · 1 comment
Open

Visual diff is not working on mkdocs, double-selects root element #12134

reteps opened this issue Apr 26, 2025 · 1 comment

Comments

@reteps
Copy link

reteps commented Apr 26, 2025

Details

Expected Result

When I click visual diff, it diffs correctly. Instead, it currently throws an error.

Image

Actual Result

this.performDiff(this.cachedRemoteResponse.content);
// ...

    const htmlDocument = parser.parseFromString(remoteContent, "text/html");
    const oldBody = htmlDocument.documentElement.querySelector(
      this.rootSelector,
    );

The JS fetches this url: https://prairielearn--11830.org.readthedocs.build/_/api/v3/embed/?url=https%3A%2F%2Fprairielearn.readthedocs.io%2Fen%2Flatest%2Fquestion%2Findex.html&maincontent=main+%3E+div+%3E+div.md-content

The content it fetches is at the root selector:

Image
Image

It then tries to select the root node of the fetched document, and fails, since it has already fetched it!

Image

Fix: don't select content at the root selector once it has been fetched through the embed link.

@reteps
Copy link
Author

reteps commented Apr 26, 2025

This looks like a regression in readthedocs/addons@a6623bf.

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

1 participant