From 7688caebe13a69012cda7d269d79ad41c852d585 Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 8 Jul 2024 10:44:01 -0700 Subject: [PATCH] Handle iframe outright failing to load in new item page preview This is a nice extra error handler to have, but note that it *won't* catch the case where the iframe successfully loads but the page returns a bad status code. In this case, we'll just show the loading state forever. --- app/assets/javascripts/outfit-viewer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/outfit-viewer.js b/app/assets/javascripts/outfit-viewer.js index 1cc16f0a..f248d7e7 100644 --- a/app/assets/javascripts/outfit-viewer.js +++ b/app/assets/javascripts/outfit-viewer.js @@ -34,6 +34,7 @@ class OutfitLayer extends HTMLElement { } else if (iframe) { this.iframe = iframe; window.addEventListener("message", (m) => this.#onMessage(m)); + this.iframe.addEventListener("error", () => this.#setStatus("error")); this.#setStatus("loading"); } else { throw new Error(` must contain an or