-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
priority: lowTo delay as much as possible.To delay as much as possible.ready to takeHelp wanted. Guidance available. There is a high chance the change will be acceptedHelp wanted. Guidance available. There is a high chance the change will be acceptedscope: systemThe system, the design tokens / styling foundations used across components. eg. @mui/system with MUIThe system, the design tokens / styling foundations used across components. eg. @mui/system with MUItype: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.
Description
Summary
We use var:
material-ui/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.tsx
Line 95 in 9f4b846
| var mode = localStorage.getItem('${modeStorageKey}') || 'system'; |
but this seems confusing. Why not let? For example, https://github.com/pacocoursey/next-themes/blob/bf0c5a45eaf6fb2b336a6b93840e4ec572bc08c8/next-themes/src/script.ts#L14 who use modern syntax.
Using let over var seems to have two benefits:
- It's less prone to bugs https://sentry.io/answers/difference-between-let-and-var-in-javascript/.
- It's easier to debug for developers, I would expect developers to not be used anymore to read code who uses
var.
Motivation
I was confused by this looking into #43416.
Metadata
Metadata
Assignees
Labels
priority: lowTo delay as much as possible.To delay as much as possible.ready to takeHelp wanted. Guidance available. There is a high chance the change will be acceptedHelp wanted. Guidance available. There is a high chance the change will be acceptedscope: systemThe system, the design tokens / styling foundations used across components. eg. @mui/system with MUIThe system, the design tokens / styling foundations used across components. eg. @mui/system with MUItype: enhancementIt’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.