diff --git a/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.tsx b/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.tsx index 7320bb7c10af42..3c7d424de6ed5e 100644 --- a/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.tsx +++ b/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.tsx @@ -92,13 +92,13 @@ export default function InitColorSchemeScript(options?: InitColorSchemeScriptPro dangerouslySetInnerHTML={{ __html: `(function() { try { - var mode = localStorage.getItem('${modeStorageKey}') || 'system'; - var colorScheme = ''; - var dark = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}'; - var light = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}'; + let colorScheme = ''; + const mode = localStorage.getItem('${modeStorageKey}') || 'system'; + const dark = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}'; + const light = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}'; if (mode === 'system') { // handle system mode - var mql = window.matchMedia('(prefers-color-scheme: dark)'); + const mql = window.matchMedia('(prefers-color-scheme: dark)'); if (mql.matches) { colorScheme = dark } else {