Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/embed-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ async function embedImageNode<T extends HTMLElement | SVGImageElement>(

const image = clonedNode as HTMLImageElement
if (image.decode) {
image.decode = resolve as any
image.onload = () => {
image.decode().finally(() => {
requestAnimationFrame(resolve)
})
}
image.decoding = 'sync'
}

if (image.loading === 'lazy') {
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export function createImage(url: string): Promise<HTMLImageElement> {
return new Promise((resolve, reject) => {
const img = new Image()
img.onload = () => {
img.decode().then(() => {
img.decode().finally(() => {
requestAnimationFrame(() => resolve(img))
})
}
Expand Down