Skip to content

Commit

Permalink
fix: fix memory leak of detached DOM tree (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn committed Dec 17, 2017
1 parent 89d5bf0 commit 7580098
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/data.ts
Expand Up @@ -4,6 +4,7 @@ import { noop, warn } from './util'

export function collectDataFromConstructor (vm: Vue, Component: VueClass<Vue>) {
// override _init to prevent to init as Vue instance
const originalInit = Component.prototype._init
Component.prototype._init = function (this: Vue) {
// proxy to actual vm
const keys = Object.getOwnPropertyNames(vm)
Expand All @@ -29,6 +30,9 @@ export function collectDataFromConstructor (vm: Vue, Component: VueClass<Vue>) {
// should be acquired class property values
const data = new Component()

// restore original _init to avoid memory leak (#209)
Component.prototype._init = originalInit

// create plain data object
const plainData = {}
Object.keys(data).forEach(key => {
Expand Down

0 comments on commit 7580098

Please sign in to comment.