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

fix #6931: Clean up target variables to avoid memory leaks #6932

Merged
merged 1 commit into from Oct 27, 2017

Conversation

fenduru
Copy link
Contributor

@fenduru fenduru commented Oct 26, 2017

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

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.

@@ -19,7 +19,7 @@ export function initEvents (vm: Component) {
}
}

let target: Component
let target: any
Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

@yyx990803 yyx990803 merged commit c355319 into vuejs:dev Oct 27, 2017
erweixin pushed a commit to erweixin/vue that referenced this pull request Dec 15, 2017
lovelope pushed a commit to lovelope/vue that referenced this pull request Feb 1, 2018
f2009 pushed a commit to f2009/vue that referenced this pull request Jan 25, 2019
aJean pushed a commit to aJean/vue that referenced this pull request Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants