Browse Source

remove reference to refElm after initial patch (fix #5851)

Evan You 9 years ago
parent
commit
07a37264c3
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/core/instance/lifecycle.js

+ 3 - 2
src/core/instance/lifecycle.js

@@ -65,6 +65,9 @@ export function lifecycleMixin (Vue: Class<Component>) {
         vm.$options._parentElm,
         vm.$options._refElm
       )
+      // no need for the ref nodes after initial patch
+      // this prevents keeping a detached DOM tree in memory (#5851)
+      vm.$options._parentElm = vm.$options._refElm = null
     } else {
       // updates
       vm.$el = vm.__patch__(prevVnode, vnode)
@@ -129,8 +132,6 @@ export function lifecycleMixin (Vue: Class<Component>) {
     if (vm.$el) {
       vm.$el.__vue__ = null
     }
-    // remove reference to DOM nodes (prevents leak)
-    vm.$options._parentElm = vm.$options._refElm = null
   }
 }