Skip to content

Commit

Permalink
Improve diff of IDL fragments
Browse files Browse the repository at this point in the history
remove syntax highlight when diffing
  • Loading branch information
dontcallmedom committed Sep 2, 2024
1 parent 94caa1e commit 1bd08a4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions amendments.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ async function listAmendments(config, _, {showError}) {
}
}

const makeIdlDiffable = pre => {
pre.querySelector(".idlHeader").remove();
pre.textContent = pre.textContent ;
};

async function showAmendments(config, _, {showError}) {
for (let section of Object.keys(amendments)) {
const target = document.getElementById(section);
Expand Down Expand Up @@ -226,6 +231,12 @@ async function showAmendments(config, _, {showError}) {
containerNew.querySelectorAll(".removeOnSave").forEach(el => el.remove());
const container = document.getElementById(section);
container.innerHTML = "";
// Use text-only content for pre - syntax highlights
// messes it up otherwise
if (containerNew.matches("pre.idl")) makeIdlDiffable(containerNew);
containerNew.querySelectorAll("pre.idl").forEach(makeIdlDiffable);
if (containerOld.matches("pre.idl")) makeIdlDiffable(containerOld);
containerOld.querySelectorAll("pre.idl").forEach(makeIdlDiffable);
await differ.diff(container, containerOld, containerNew);
container.parentNode.insertBefore(wrapper, container);
} else if (amendments[section][0].difftype === "append") {
Expand Down

0 comments on commit 1bd08a4

Please sign in to comment.