Skip to content

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

Open
@reteps

Description

@reteps

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AcceptedAccepted issue on our roadmapBugA bug

    Type

    No type

    Projects

    Status

    Planned

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions