fix bug where image load errors would keep loading

Dice reported this, thank you!

My mistake here was that `loadImage` _does_ reject when the image fails to load… but it ends up throwing `undefined`, since I forgot to pass the error along from `onerror` to `reject`!

So we would cancel stuff, but then store `undefined` as our error in state, which our component interprets as no-error.

I tested this by using Firefox DevTools request blocking!
This commit is contained in:
Emi Matchu 2020-08-19 19:11:49 -07:00
parent f8e625afd2
commit 700073df8a

View file

@ -212,7 +212,7 @@ function loadImage(url) {
const image = new Image();
const promise = new Promise((resolve, reject) => {
image.onload = () => resolve();
image.onerror = () => reject();
image.onerror = (e) => reject(e);
image.src = url;
});
promise.cancel = () => {