File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
platforms/web/runtime/components Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,14 @@ import {
2121export let activeInstance : any = null
2222export let isUpdatingChildComponent : boolean = false
2323
24+ export function setActiveInstance ( vm : Component ) {
25+ const prevActiveInstance = activeInstance
26+ activeInstance = vm
27+ return ( ) => {
28+ activeInstance = prevActiveInstance
29+ }
30+ }
31+
2432export function initLifecycle ( vm : Component ) {
2533 const options = vm . $options
2634
@@ -52,8 +60,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
5260 const vm : Component = this
5361 const prevEl = vm . $el
5462 const prevVnode = vm . _vnode
55- const prevActiveInstance = activeInstance
56- activeInstance = vm
63+ const restoreActiveInstance = setActiveInstance ( vm )
5764 vm . _vnode = vnode
5865 // Vue.prototype.__patch__ is injected in entry points
5966 // based on the rendering backend used.
@@ -64,7 +71,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
6471 // updates
6572 vm . $el = vm . __patch__ ( prevVnode , vnode )
6673 }
67- activeInstance = prevActiveInstance
74+ restoreActiveInstance ( )
6875 // update __vue__ reference
6976 if ( prevEl ) {
7077 prevEl . __vue__ = null
Original file line number Diff line number Diff line change 1414import { warn , extend } from 'core/util/index'
1515import { addClass , removeClass } from '../class-util'
1616import { transitionProps , extractTransitionData } from './transition'
17+ import { setActiveInstance } from 'core/instance/lifecycle'
1718
1819import {
1920 hasTransition ,
@@ -36,6 +37,7 @@ export default {
3637 beforeMount ( ) {
3738 const update = this . _update
3839 this . _update = ( vnode , hydrating ) => {
40+ const restoreActiveInstance = setActiveInstance ( this )
3941 // force removing pass
4042 this . __patch__ (
4143 this . _vnode ,
@@ -44,6 +46,7 @@ export default {
4446 true // removeOnly (!important, avoids unnecessary moves)
4547 )
4648 this . _vnode = this . kept
49+ restoreActiveInstance ( )
4750 update . call ( this , vnode , hydrating )
4851 }
4952 } ,
You can’t perform that action at this time.
0 commit comments