From 23f01c451b5fca78d2cdccd1c2750fbabb87aa47 Mon Sep 17 00:00:00 2001 From: psvenk <45520974+psvenk@users.noreply.github.com> Date: Mon, 29 Jul 2019 12:27:26 -0400 Subject: [PATCH] Change double equals to triple equals Use strict equality, to avoid type coercion and conform to JS best practices (as suggested by @leonklingele). --- assets/js/themes.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/themes.js b/assets/js/themes.js index 9388d422..223d01f5 100644 --- a/assets/js/themes.js +++ b/assets/js/themes.js @@ -17,7 +17,7 @@ toggle_theme.addEventListener('click', function () { }); window.addEventListener('storage', function (e) { - if (e.key == 'dark_mode') { + if (e.key === 'dark_mode') { update_mode(e.newValue); } }); @@ -38,11 +38,11 @@ function set_mode (bool) { } function update_mode (mode) { - if (mode == 'true' /* for backwards compatibility */ || mode == 'dark') { + if (mode === 'true' /* for backwards compatibility */ || mode === 'dark') { // If dark mode preference set set_mode(true); } - else if (mode != 'light' && window.matchMedia('(prefers-color-scheme: dark)').matches) { + else if (mode !== 'light' && window.matchMedia('(prefers-color-scheme: dark)').matches) { // If no preference set, but the browser tells us that the operating system has a dark theme set_mode(true); }