bubkoo / html-to-image

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

toBlob error when image not found #336

Open liu-xinhui opened 1 year ago

liu-xinhui commented 1 year ago

Expected Behavior

Do not show error, when image not found ,make it empty

Current Behavior

show error and not create image

Possible Solution

Steps To Reproduce

  1. ...
  2. ...
  3. ...
Error Message & Stack Trace

```txt ```

Additional Context

Your Environment

image
vivcat[bot] commented 1 year ago

👋 @liu-xinhui

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.

yairbar commented 1 year ago

it's happened to me too,

https://github.com/bubkoo/html-to-image/blob/master/src/embed-images.ts#L27

need to fix

!isDataUrl(clonedNode.src) => !isDataUrl(clonedNode.src || '')

for cases there is not 'src' in <img> element