diff --git a/public/js/index.js b/public/js/index.js index 772fd44..8b4d369 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -17,7 +17,8 @@ const setMetaTheme = () => { // EVENT LISTENER //////////////////////////////////////////////////////// btnTheme.addEventListener('click', () => { - const themeToSet = document.documentElement.getAttribute('theme') === 'light' ? 'dark' : 'light'; + const curTheme = document.documentElement.getAttribute('theme') ?? 'light'; + const themeToSet = curTheme === 'light' ? 'dark' : 'light'; setTheme(themeToSet); if (isLocalStorageAccessible()) localStorage.setItem('theme', themeToSet); setMetaTheme();