The homepage has no #content, so elem would be null and an error would be thrown without this check.

This commit is contained in:
Greenscreener 2021-08-04 11:41:33 +02:00
parent ebd2774eab
commit d3fc74e9ee

View File

@ -3,7 +3,7 @@ function restoreDarkmode() {
const elem = document.getElementById("content");
if (!document.cookie.includes("dark-mode=")) {
if (prefersDarkMode.matches) {
if (elem && prefersDarkMode.matches) {
elem.classList.add("dark-mode");
}
}