-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fix: avoid hoisting error by using 'let' instead of 'var' #11291
fix: avoid hoisting error by using 'let' instead of 'var' #11291
Conversation
🦋 Changeset detectedLatest commit: 583de86 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just realized the same bug happens for opts
and event_name
, they need to be let, too
I think this can still cause an issue in the future because A more minimal fix that is more robust is not hoisting Although, this is the second bug related to |
@harrisi While Though, I do agree that |
Yeah I have always wondered why this project extensively uses var. |
|
Unfortunately, efficient code sometimes requires weird stuff. |
In that issue you can see that the performance difference is considered a bug in v8. There's an open issue about it. Regardless, this feels like the wrong place for this discussion. I may open an issue at some point about it, since it feels like it goes against most of the tenets Rich posted about. |
It does not. This is the nitty gritty nasty details that allow you to write nice performant Svelte code and has nothing to do with the public-facing API |
Fixes #11284
There was a small bug introduced by #11230 where it referenced
value
within a closure, butvalue
was declared withvar
instead oflet
. This created a situation wherevalue
was hoisted and thus any changes tovalue
would be propagated to the closure rather than it maintaining the intended value. Usinglet
instead ofvar
here keeps the scoping ofvalue
correct for the closure.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint