Merge pull request #87 from MeiK2333/fix-icon-null

Fixes #86
This commit is contained in:
MeiK
2021-12-07 16:08:31 +08:00
committed by GitHub

View File

@@ -1,18 +1,22 @@
function switchTheme() {
const currentStyle = currentTheme();
var iconElement = document.getElementById('github-icon');
const iconElement = document.getElementById('github-icon');
if (currentStyle == 'light') {
if (currentStyle === 'light') {
setTheme('dark');
if (iconElement) {
iconElement.setAttribute('class', 'octicon');
iconElement.setAttribute('color', '#f0f6fc');
}
}
else {
setTheme('light');
if (iconElement) {
iconElement.removeAttribute('color');
iconElement.removeAttribute('class');
}
}
}
function setTheme(style) {
document.querySelectorAll('.isInitialToggle').forEach(elem => {