Skip to content

Commit

Permalink
Adding error handling to embedWebFonts and embedImages
Browse files Browse the repository at this point in the history
  • Loading branch information
zgw010 authored Nov 25, 2024
1 parent 128dc3e commit 712af48
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ export async function toSvg<T extends HTMLElement>(
): Promise<string> {
const { width, height } = getImageSize(node, options)
const clonedNode = (await cloneNode(node, options, true)) as HTMLElement
await embedWebFonts(clonedNode, options)
await embedImages(clonedNode, options)
try {
await embedWebFonts(clonedNode, options);
} catch (error) {
console.log('[embedWebFonts error]', error);
}
try {
await embedImages(clonedNode, options);
} catch (error) {
console.log('[embedImages error]', error);
}
applyStyle(clonedNode, options)
const datauri = await nodeToDataURL(clonedNode, width, height)
return datauri
Expand Down

0 comments on commit 712af48

Please sign in to comment.