diff options
author | Dillon <dillonzq@outlook.com> | 2020-04-27 20:38:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 20:38:22 +0300 |
commit | 6805d695f6ee1ba6b774a9ae518b85c8030bfa08 (patch) | |
tree | 7af9ef0530b345ba0805ce4db4bdb8fa6c0de381 /src | |
parent | b46c81053f7a4307945b82bee6944af7e6e13d1c (diff) |
chore: update docs and style (#269)
Diffstat (limited to 'src')
-rw-r--r-- | src/js/theme.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/js/theme.js b/src/js/theme.js index bf00f1bb..ef56582c 100644 --- a/src/js/theme.js +++ b/src/js/theme.js @@ -32,7 +32,7 @@ class Theme { constructor() { this.config = window.config; this.data = this.config.data; - this.isDark = document.body.classList.contains('dark'); + this.isDark = document.body.getAttribute('theme') === 'dark'; this.util = new Util(); this.newScrollTop = this.util.getScrollTop(); this.oldScrollTop = this.newScrollTop; @@ -80,7 +80,8 @@ class Theme { initSwitchTheme() { this.util.forEach(document.getElementsByClassName('theme-switch'), $themeSwitch => { $themeSwitch.addEventListener('click', () => { - document.body.classList.toggle('dark'); + if (document.body.getAttribute('theme') === 'dark') document.body.setAttribute('theme', 'light'); + else document.body.setAttribute('theme', 'dark'); this.isDark = !this.isDark; window.localStorage && localStorage.setItem('theme', this.isDark ? 'dark' : 'light'); for (let event of this.switchThemeEventSet) event(); |