-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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 #6931: Clean up target variables to avoid memory leaks #6932
Conversation
d533cfe
to
d7e14f6
Compare
@@ -19,7 +19,7 @@ export function initEvents (vm: Component) { | |||
} | |||
} | |||
|
|||
let target: Component | |||
let target: any |
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.
I don't love removing the type annotation here, but if I left it as Component
then Flow would see the assignment to undefined and error due to "Possible undefined value".
In typescript you can tell the type checker to trust you by doing target!.method()
but I couldn't find an equivilent in Flow. The Flow docs recommend if (target !== undefined)
, however I didn't think we'd want to add a branch in the VDom code.
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.
What about just binding the add
and remove
methods to the vm
so you don't need this closure variable at all?
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.
@chriscasola You won't wanna do it that way. function.bind is just create a closure.
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
The development environment on Windows is flaky and crashes a lot. I'm also seeing intermittent failures that seem unrelated to my change (they also occur on the
dev
branch with no changes). Filing the PR now to get feedback and to see if CI has the same failures.