|
|
@@ -21,6 +21,14 @@ import {
|
|
|
export let activeInstance: any = null
|
|
|
export let isUpdatingChildComponent: boolean = false
|
|
|
|
|
|
+export function setActiveInstance(vm: Component) {
|
|
|
+ const prevActiveInstance = activeInstance
|
|
|
+ activeInstance = vm
|
|
|
+ return () => {
|
|
|
+ activeInstance = prevActiveInstance
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export function initLifecycle (vm: Component) {
|
|
|
const options = vm.$options
|
|
|
|
|
|
@@ -52,8 +60,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
|
|
|
const vm: Component = this
|
|
|
const prevEl = vm.$el
|
|
|
const prevVnode = vm._vnode
|
|
|
- const prevActiveInstance = activeInstance
|
|
|
- activeInstance = vm
|
|
|
+ const restoreActiveInstance = setActiveInstance(vm)
|
|
|
vm._vnode = vnode
|
|
|
// Vue.prototype.__patch__ is injected in entry points
|
|
|
// based on the rendering backend used.
|
|
|
@@ -64,7 +71,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
|
|
|
// updates
|
|
|
vm.$el = vm.__patch__(prevVnode, vnode)
|
|
|
}
|
|
|
- activeInstance = prevActiveInstance
|
|
|
+ restoreActiveInstance()
|
|
|
// update __vue__ reference
|
|
|
if (prevEl) {
|
|
|
prevEl.__vue__ = null
|