Fixes issue when localStorage is disabled
This commit is contained in:
parent
d4ba47cd21
commit
0aae2d0678
@ -43,7 +43,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function detectCurrentScheme() {
|
function detectCurrentScheme() {
|
||||||
if (localStorage.getItem(STORAGE_KEY)) {
|
if (localStorage !== null && localStorage.getItem(STORAGE_KEY)) {
|
||||||
return localStorage.getItem(STORAGE_KEY)
|
return localStorage.getItem(STORAGE_KEY)
|
||||||
}
|
}
|
||||||
if (defaultTheme) {
|
if (defaultTheme) {
|
||||||
@ -67,11 +67,13 @@ function changeButtonText()
|
|||||||
|
|
||||||
function switchTheme(e) {
|
function switchTheme(e) {
|
||||||
if (currentTheme == 'dark') {
|
if (currentTheme == 'dark') {
|
||||||
localStorage.setItem(STORAGE_KEY, 'light')
|
if (localStorage !== null)
|
||||||
|
localStorage.setItem(STORAGE_KEY, 'light')
|
||||||
document.documentElement.setAttribute('data-theme', 'light')
|
document.documentElement.setAttribute('data-theme', 'light')
|
||||||
currentTheme = 'light'
|
currentTheme = 'light'
|
||||||
} else {
|
} else {
|
||||||
localStorage.setItem(STORAGE_KEY, 'dark')
|
if (localStorage !== null)
|
||||||
|
localStorage.setItem(STORAGE_KEY, 'dark')
|
||||||
document.documentElement.setAttribute('data-theme', 'dark')
|
document.documentElement.setAttribute('data-theme', 'dark')
|
||||||
currentTheme = 'dark'
|
currentTheme = 'dark'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user