Add some extra guards around image loading

This commit is contained in:
Matt Bierner 2020-05-27 19:56:02 -07:00
parent fa3150fef0
commit 7a4880a6bd

View file

@ -279,6 +279,9 @@
image.classList.add('scale-to-fit');
image.addEventListener('load', () => {
if (hasLoadedImage) {
return;
}
hasLoadedImage = true;
vscode.postMessage({
@ -297,7 +300,11 @@
}
});
image.addEventListener('error', () => {
image.addEventListener('error', e => {
if (hasLoadedImage) {
return;
}
hasLoadedImage = true;
document.body.classList.add('error');
document.body.classList.remove('loading');