Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[system] initColorSchemeScript.tsx uses var instead of let #43418

Closed
oliviertassinari opened this issue Aug 24, 2024 · 4 comments · Fixed by #43468
Closed

[system] initColorSchemeScript.tsx uses var instead of let #43418

oliviertassinari opened this issue Aug 24, 2024 · 4 comments · Fixed by #43468
Labels
enhancement This is not a bug, nor a new feature package: system Specific to @mui/system priority: low To delay as much as possible ready to take Help wanted. Guidance available. There is a high chance the change will be accepted

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 24, 2024

Summary

We use var:

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:

Motivation

I was confused by this looking into #43416.

@oliviertassinari oliviertassinari added package: system Specific to @mui/system status: waiting for maintainer These issues haven't been looked at yet by a maintainer enhancement This is not a bug, nor a new feature labels Aug 24, 2024
@siriwatknp siriwatknp added ready to take Help wanted. Guidance available. There is a high chance the change will be accepted good first issue Great for first contributions. Enable to learn the contribution process. and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 26, 2024
@ilyastorunn
Copy link

Hi, would you like to create a PR?

@ishon19
Copy link
Contributor

ishon19 commented Aug 26, 2024

Hi, would you like to create a PR?

Hey @ilyastorunn! I can do that, but go ahead if you have one ready.

@m-sathish-varma
Copy link

Hi @oliviertassinari,
var might have been used because the code was written in an environment where ES6 (let and const) was not supported, or it’s older code.

@Michael-Hutchinson

This comment was marked as resolved.

@oliviertassinari oliviertassinari added priority: low To delay as much as possible and removed good first issue Great for first contributions. Enable to learn the contribution process. labels Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is not a bug, nor a new feature package: system Specific to @mui/system priority: low To delay as much as possible ready to take Help wanted. Guidance available. There is a high chance the change will be accepted
Projects
None yet
6 participants