From 63960e74d92ce3fe55ddbf4ee839f1dfcd4e1740 Mon Sep 17 00:00:00 2001 From: AlejandroSuero Date: Fri, 3 May 2024 15:01:08 +0200 Subject: [PATCH] fix(ClipsModal): linting errors --- src/components/ClipsModal.astro | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/ClipsModal.astro b/src/components/ClipsModal.astro index 278cbde2b..02875b61f 100644 --- a/src/components/ClipsModal.astro +++ b/src/components/ClipsModal.astro @@ -63,8 +63,8 @@ const $clipContainer = $$(".clip-container") const $clipDialog = $(".clip-dialog") as HTMLDialogElement const $closeButton = $(".close-dialog") - const $ytFrame = $(".yt-iframe") - const ytFrameCopy = $ytFrame + let $ytFrame = $(".yt-iframe") + const ytFrameCopy = $ytFrame if (!$clipDialog) return @@ -72,7 +72,7 @@ if ($ytFrame !== null) { $ytFrame.setAttribute("src", "") } else { - ytFrameCopy.setAttribute("src", "") + ytFrameCopy?.setAttribute("src", "") } }) @@ -81,7 +81,7 @@ if ($ytFrame !== null) { $ytFrame.remove() } else { - ytFrameCopy.remove() + ytFrameCopy?.remove() } }) @@ -95,12 +95,14 @@ const currentTarget = event.currentTarget as HTMLElement const { url } = currentTarget.dataset if (!url) return - $ytFrame = document.querySelector(".yt-iframe") as HTMLIFrameElement + $ytFrame = $(".yt-iframe") as HTMLIFrameElement if ($ytFrame !== null) { $ytFrame.setAttribute("src", `${url}&autoplay=1`) } else { - $clipDialog?.querySelector("div")?.prepend(ytFrameCopy) - ytFrameCopy.setAttribute("src", `${url}&autoplay=1`) + if (ytFrameCopy) { + $clipDialog?.querySelector("div")?.prepend(ytFrameCopy) + ytFrameCopy.setAttribute("src", `${url}&autoplay=1`) + } } $clipDialog.showModal() })