(github.com)
The most significant roadblock was that drawing SVG <foreignObject> with inline subresources (data: and blob: URIs) tainted canvases in Chrome and Safari, and this was partially resolved in 2019[1].
Notably, some issues still remain but apparently it's now workable. As is apparent from snapDOM, completely accurate CSS normalization is still an unsolved problem.
While I'm excited to see the HTML-in-foreignObject use case mature, it is also important to point out that the Media Capture API now has the ability to capture individual elements natively in Chrome[2].
1. https://issues.chromium.org/issues/41054640#comment49
2. https://developer.mozilla.org/en-US/docs/Web/API/CropTarget/...
html2canvas: https://i.imgur.com/zfSwNR1.png
snapdom: https://i.imgur.com/FxowTzp.png
Also I recommend putting the npm package name clearly in your README. I guess I don't really know what other people are doing these days, but I think most people are like me and consume packages like this from npm rather than a <script> tag.
I’ve run some performance tests using Vitest Bench, and SnapDOM was faster. I also created a few manual demos, and SnapDOM won in both speed and accuracy.
That said, I still need to run more real-world tests. So, thanks again for your help!
Whether that's faster or more reliable, I don't know. Seems likely to render different depending on where you view the SVG (especially out of browsers).
[0]: https://github.com/search?q=repo%3Azumerlab%2Fsnapdom%20fore...
I've been using CropTarget.fromElement with a CaptureController: https://gist.github.com/akre54/e93ab2ce27999aecb109e38085f2e...
For most cases, the Element Capture or Region Capture API should be sufficient: https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capt...
Demos: https://mdn.github.io/dom-examples/screen-capture-api/elemen... https://mdn.github.io/dom-examples/screen-capture-api/region...
If you need cross-browser compatibility (and can't just use a canvas) then yeah html2canvas is the way to go
Plus it just struck at pending promise dont work
Plus css is messed up, i cant call it a snapshot, if it dont look same
domtoimage lib works for me and is fast whole html body node captured within second