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

createElement to use block-scoped variables in for...in loops #31821

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wo-o29
Copy link

@wo-o29 wo-o29 commented Dec 17, 2024

Summary

This PR fix the createElement function to use block-scoped variables (const) in for...in loops instead of declaring the variable (let propName) at the function scope. This change aligns with modern JavaScript best practices, improving code readability and safety.

Changes

  1. Replaced the function-scoped variable declaration (let propName) with block-scoped declarations (const) directly inside the for...in loops.
  2. Ensured that all loops remain functionally identical to the previous implementation.

Benefits

  • Improves code readability by limiting the scope of loop variables to their respective loops.
  • Aligns with modern ES6+ standards and best practices for variable scoping.
  • Reduces potential for unintended side effects caused by reusing a single variable across multiple loops.

Additional Notes

This change is purely a refactor and does not alter any functionality of the createElement API.

Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 2:58pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants