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,16 +1,20 @@
function switchTheme() { function switchTheme() {
const currentStyle = currentTheme(); const currentStyle = currentTheme();
var iconElement = document.getElementById('github-icon'); const iconElement = document.getElementById('github-icon');
if (currentStyle == 'light') { if (currentStyle === 'light') {
setTheme('dark'); setTheme('dark');
iconElement.setAttribute('class', 'octicon'); if (iconElement) {
iconElement.setAttribute('color', '#f0f6fc'); iconElement.setAttribute('class', 'octicon');
iconElement.setAttribute('color', '#f0f6fc');
}
} }
else { else {
setTheme('light'); setTheme('light');
iconElement.removeAttribute('color'); if (iconElement) {
iconElement.removeAttribute('class'); iconElement.removeAttribute('color');
iconElement.removeAttribute('class');
}
} }
} }