Skip to content

Commit

Permalink
remove parent/ref elm references when destroying instance, fix memory…
Browse files Browse the repository at this point in the history
… leak (fix vue-router#1279)
  • Loading branch information
yyx990803 committed Mar 27, 2017
1 parent be07617 commit 3209f6f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/instance/lifecycle.js
Expand Up @@ -119,15 +119,18 @@ export function lifecycleMixin (Vue: Class<Component>) {
}
// call the last hook...
vm._isDestroyed = true
// invoke destroy hooks on current rendered tree
vm.__patch__(vm._vnode, null)
// fire destroyed hook
callHook(vm, 'destroyed')
// turn off all instance listeners.
vm.$off()
// remove __vue__ reference
if (vm.$el) {
vm.$el.__vue__ = null
}
// invoke destroy hooks on current rendered tree
vm.__patch__(vm._vnode, null)
// remove reference to DOM nodes (prevents leak)
vm.$options._parentElm = vm.$options._refElm = null
}
}

Expand Down

0 comments on commit 3209f6f

Please sign in to comment.