From bc96f422684ff0998254d18031f5ad6eb9c08943 Mon Sep 17 00:00:00 2001 From: Greenscreener Date: Sat, 9 Nov 2019 15:21:03 +0100 Subject: [PATCH] Resolved error from comment on commit b5013b58. --- themes/patek/assets/js/dark-mode.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/themes/patek/assets/js/dark-mode.js b/themes/patek/assets/js/dark-mode.js index 8d24f97..0869cc5 100644 --- a/themes/patek/assets/js/dark-mode.js +++ b/themes/patek/assets/js/dark-mode.js @@ -1,21 +1,13 @@ document.addEventListener("DOMContentLoaded", () => { if (window.location.search.indexOf("darkmode=false") > -1) { document.cookie = "darkmode=false; path=/"; - try { + if (document.getElementById("content") !== null) { document.getElementById("content").classList.remove("dark-mode"); - } catch (error) { - if (error.message !== "document.getElementById(...) is null") { - throw error; - } } } else if (window.location.search.indexOf("darkmode=true") > -1 || document.cookie.indexOf("darkmode=true") > -1) { document.cookie = "darkmode=true; path=/"; - try { + if (document.getElementById("content") !== null) { document.getElementById("content").classList.add("dark-mode"); - } catch (error) { - if (error.message !== "document.getElementById(...) is null") { - throw error; - } } } });