From 4f18f3ac202a0f1963a134b4d1d9bb803c7ee0e8 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sat, 9 Jul 2022 11:38:31 +0100 Subject: [PATCH] FIX: Ensure splash screen logic is iOS12 compatible (#17401) The `?.` safe navigation operator is not supported, and inline scripts are not run through babel. --- app/views/common/_discourse_splash.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/common/_discourse_splash.html.erb b/app/views/common/_discourse_splash.html.erb index 8ec585593f1..27adc2950ff 100644 --- a/app/views/common/_discourse_splash.html.erb +++ b/app/views/common/_discourse_splash.html.erb @@ -226,12 +226,12 @@ const encodedSvg = btoa(svgString); const splashWrapper = document.querySelector("#d-splash"); - const splashImage = splashWrapper?.querySelector(".preloader-image"); + const splashImage = splashWrapper && splashWrapper.querySelector(".preloader-image"); if (splashImage) { splashImage.src = `data:image/svg+xml;base64,${encodedSvg}`; - const connectStart = performance?.timing?.connectStart || 0; + const connectStart = performance.timing.connectStart || 0; const splashDelay = connectStart ? DELAY_TARGET : 0; const targetTime = connectStart + DELAY_TARGET; @@ -239,8 +239,8 @@ let discourseReady; const swapSplash = () => { - splashWrapper?.style.setProperty("--animation-state", "running"); - svgElement?.style.setProperty("--animation-state", "running"); + splashWrapper && splashWrapper.style.setProperty("--animation-state", "running"); + svgElement && svgElement.style.setProperty("--animation-state", "running"); const newSvgString = new XMLSerializer().serializeToString(svgElement); const newEncodedSvg = btoa(newSvgString); @@ -273,7 +273,7 @@ "discourse-ready", () => { discourseReady = true; - splashWrapper?.remove(); + splashWrapper && splashWrapper.remove(); performance.mark("discourse-splash-removed"); }, { once: true }