From 54993f1b070d0677ebcf55740704f47df9c288d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20R=C3=B6nn?= Date: Tue, 15 Sep 2020 21:19:38 +0200 Subject: [PATCH] - Improved the code in util.js to not throw errors if halfmoon is removed in the future --- app/util.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/util.js b/app/util.js index d4379a1..5df8261 100644 --- a/app/util.js +++ b/app/util.js @@ -1,9 +1,11 @@ -halfmoon.showModal = id => { - const t = document.getElementById(id) - t && t.classList.add("show") -} -halfmoon.hideModal = id => { - const t = document.getElementById(id) - t && t.classList.remove("show") +if ((typeof halfmoon === "object" || typeof halfmoon === 'function') && (halfmoon !== null)) { + halfmoon.showModal = id => { + const t = document.getElementById(id) + t && t.classList.add("show") + } + halfmoon.hideModal = id => { + const t = document.getElementById(id) + t && t.classList.remove("show") + } }