bubkoo / html-to-image

✂️ Generates an image from a DOM node using HTML5 canvas and SVG.
MIT License
5.4k stars 505 forks source link

toSvg, toPng, etc Got TypeError: e.toDataURL is not a function on 1.11.6 onwards #386

Open kmcheung12 opened 1 year ago

kmcheung12 commented 1 year ago

Expected Behavior

Used in a web browser extension, can obtain rendered image of an html element

Current Behavior

For version 1.11.6 (inclusive) onward, it gives error TypeError: e.toDataURL is not a function on APIs toPng, toSvg and toCanvas. (Unverified on the rest of public APIs). Version 1.11.5 is working as intended

Possible Solution

The introduction of isInstanceOfElement in 1.11.6's cloneChildren might be the cause. The comparison logic in isInstanceOfElement might be not completely equivalent to older version

Steps To Reproduce

  1. Create a typescript based browser extension
  2. Add html-to-image as dependency
  3. Screen capture document.body on example.com
  4. Reproducible example at https://github.com/kmcheung12/html-to-image-bug-reproduction
  5. Working behaviour with version 1.11.5 in branch https://github.com/kmcheung12/html-to-image-bug-reproduction/tree/older-but-working
  6. Screenshots available in the repo
Error Message & Stack Trace

```txt TypeError: e.toDataURL is not a function ```

Additional Context

Your Environment

vivcat[bot] commented 1 year ago

👋 @kmcheung12

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.