From 9512bbb19400be6b770735ceb6daca4e71429630 Mon Sep 17 00:00:00 2001 From: welpo Date: Fri, 28 Apr 2023 16:38:46 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20use=20`const`?= =?UTF-8?q?=20in=20theme=20initialization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor the theme initialization script to use 'const' instead of 'let' for the 'currentTheme' variable, as the value is not expected to change after initialization. This makes the code more clear and prevents accidental re-assignment. --- static/js/initialize_theme.js | 2 +- static/js/initialize_theme_min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/initialize_theme.js b/static/js/initialize_theme.js index 688b0ff..45ba7f6 100644 --- a/static/js/initialize_theme.js +++ b/static/js/initialize_theme.js @@ -1,5 +1,5 @@ (function () { - let currentTheme = localStorage.getItem('theme'); + const currentTheme = localStorage.getItem('theme'); if (currentTheme) { document.documentElement.setAttribute('data-theme', currentTheme); } else { diff --git a/static/js/initialize_theme_min.js b/static/js/initialize_theme_min.js index 9463f4b..eee5bc4 100644 --- a/static/js/initialize_theme_min.js +++ b/static/js/initialize_theme_min.js @@ -1 +1 @@ -!function(){let e=localStorage.getItem("theme");if(e)document.documentElement.setAttribute("data-theme",e);else{let t=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.setAttribute("data-theme",t?"dark":"light")}}(); +!function(){const e=localStorage.getItem("theme");if(e)document.documentElement.setAttribute("data-theme",e);else{const t=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.setAttribute("data-theme",t?"dark":"light")}}();