From ee629a160586dcc502a5cc1d945adcba11e0b60c Mon Sep 17 00:00:00 2001 From: mishchuk Date: Fri, 21 Oct 2022 11:00:37 +1000 Subject: [PATCH] Fix unhandled rejection "EncodingError: The source image cannot be decoded" https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode-dev --- src/js/slide/content.js | 2 +- src/js/util/util.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/slide/content.js b/src/js/slide/content.js index b6b7152b..c7468c31 100644 --- a/src/js/slide/content.js +++ b/src/js/slide/content.js @@ -417,7 +417,7 @@ class Content { // purposefully using finally instead of then, // as if srcset sizes changes dynamically - it may cause decode error /** @type {HTMLImageElement} */ - (this.element).decode().finally(() => { + (this.element).decode().catch(() => {}).finally(() => { this.isDecoding = false; this.appendImage(); }); diff --git a/src/js/util/util.js b/src/js/util/util.js index 4c71613a..197b437e 100644 --- a/src/js/util/util.js +++ b/src/js/util/util.js @@ -154,7 +154,7 @@ export function removeTransitionStyle(el) { */ export function decodeImage(img) { if ('decode' in img) { - return img.decode(); + return img.decode().catch(() => {}); } if (img.complete) {