fix: add optional chaining for theme switch event listener

Add optional chaining in the event listener of the theme switch button in toggle-theme.js file. This
is to avoid occuring an error in the console when `light & dark theme mode` is disabled.
This commit is contained in:
satnaing
2022-11-28 21:23:15 +06:30
parent b05b6654f6
commit c4c9ab2246
+1 -1
View File
@@ -37,7 +37,7 @@ window.onload = () => {
reflectPreference();
// now this script can find and listen for clicks on the control
document.querySelector("#theme-btn").addEventListener("click", () => {
document.querySelector("#theme-btn")?.addEventListener("click", () => {
themeValue = themeValue === "light" ? "dark" : "light";
setPreference();
});