Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Commit

Permalink
website_render: replace canvas with dataURLs
Browse files Browse the repository at this point in the history
This fixes the example output of imread, which previously needed
to be executed before seeing the image.
http://127.0.0.1:8080/docs/#imread
  • Loading branch information
ry committed Mar 23, 2018
1 parent b862e6a commit 62d9f57
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/website_render.js
Expand Up @@ -36,6 +36,16 @@ async function puppetRender(browser, url) {
// Remove sandbox iframes.
Array.from(document.getElementsByTagName("iframe"))
.forEach(el => el.parentNode.removeChild(el));

// Replace canvas images with dataURLs
const canvases = Array.from(document.querySelectorAll("canvas"));
for (const c of canvases) {
const dataURL = c.toDataURL();
const img = document.createElement("img");
img.setAttribute("src", dataURL);
c.parentNode.replaceChild(img, c);
}

return document.documentElement.innerHTML;
}
);
Expand Down

0 comments on commit 62d9f57

Please sign in to comment.