-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Closed
Labels
Milestone
Description
Description
Hey the code that is in the else block has no right to work. (readAsDataURL is not return result)
I'm so wondering if it's worth fix it or maybe remove the whole else block?
https://caniuse.com/?search=toDataURL
toDataURL has a lot of support so probably no one has had problems but it's weird looking at incorrect code. 😅
Solution
just remove else block
Alternatives
Fix it :
if (canvas.toDataURL !== undefined) {
imageDef.uri = canvas.toDataURL(mimeType);
} else {
pending.push(
getToBlobPromise(canvas, mimeType)
.then((blob) => {
const fileReader = new FileReader();
fileReader.readAsDataURL(blob);
return new Promise((resolve) => {
fileReader.addEventListener('load', function () {
resolve(fileReader.result);
});
});
})
.then((dataURL) => {
imageDef.uri = dataURL;
}),
);
}
Additional context
No response
Mugen87