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: it's comparing static HTML vs. JavaScript generated one #528

Open
humitos opened this issue Feb 11, 2025 · 1 comment
Open
Labels
Improvement Minor improvement to code Needed: design decision A core team decision is required

Comments

@humitos
Copy link
Member

humitos commented Feb 11, 2025

I found a few examples where some extra HTML tags are added to the DOM in current page the user is reading. At that point, if the user enables visual diff, it fetch the raw HTML file without applying any JavaScript modification to its DOM resulting on having a few diff chunks on places where the HTML didn't change in reality.

It seems that CPython adds a Copy button on their Python code chunks using JavaScript and we identify this as diff chunk:

<ins class="doc-diff-added">
  <span class="copybutton" title="Hide the prompts and output" data-hidden="false">
  &gt;&gt;&gt;
  </span>
</ins>

I found this in python/cpython#125565, but it should happen in any other project that modifies the DOM using JavaScript. I'm sure what's the solution, but we may want to render the current DOM with JavaScript disabled and use that for the comparison.

@humitos humitos added Improvement Minor improvement to code Needed: design decision A core team decision is required labels Feb 11, 2025
@humitos
Copy link
Member Author

humitos commented Feb 11, 2025

I did a quick test and it definitely works better regarding identifying the diff chunks. The "downside" is that all the HTML element that were regenerated/added with JavaScript won't be shown when "Visual diff" is enabled --which probably makes sense. In the previous example I mentioned, the Copy buttons will disappear when "Visual diff" is enabled:

Peek.2025-02-11.10-51.webm

@github-project-automation github-project-automation bot moved this to Planned in 📍Roadmap Feb 11, 2025
@humitos humitos changed the title Visual Diff: we are comparing static HTML vs. JavaScript generated one Visual Diff: it's comparing static HTML vs. JavaScript generated one Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code Needed: design decision A core team decision is required
Projects
Status: Planned
Development

No branches or pull requests

1 participant