Skip to content

Commit

Permalink
fix: initialize script on the case of disabling color toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jan 27, 2023
1 parent dbe5b0a commit 4e82cc6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions assets/js/mode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ class ModeToggle implements Component {
}
});

const icon = document
.querySelector('.mode-item[data-color-mode="' + mode + '"] .mode-icon')
.cloneNode(true) as HTMLElement;
const icon = document.querySelector('.mode-item[data-color-mode="' + mode + '"] .mode-icon')?.cloneNode(true) as HTMLElement;
if (!icon) {
return
}

icon.setAttribute('id', 'modeIcon');
document.querySelector('#modeIcon').replaceWith(icon);
document.querySelector('#modeIcon')?.replaceWith(icon);
}

setMode(value: string) {
Expand Down

0 comments on commit 4e82cc6

Please sign in to comment.