File tree 2 files changed +13
-3
lines changed
platforms/web/runtime/components
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,14 @@ import {
21
21
export let activeInstance : any = null
22
22
export let isUpdatingChildComponent : boolean = false
23
23
24
+ export function setActiveInstance ( vm : Component ) {
25
+ const prevActiveInstance = activeInstance
26
+ activeInstance = vm
27
+ return ( ) => {
28
+ activeInstance = prevActiveInstance
29
+ }
30
+ }
31
+
24
32
export function initLifecycle ( vm : Component ) {
25
33
const options = vm . $options
26
34
@@ -52,8 +60,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
52
60
const vm : Component = this
53
61
const prevEl = vm . $el
54
62
const prevVnode = vm . _vnode
55
- const prevActiveInstance = activeInstance
56
- activeInstance = vm
63
+ const restoreActiveInstance = setActiveInstance ( vm )
57
64
vm . _vnode = vnode
58
65
// Vue.prototype.__patch__ is injected in entry points
59
66
// based on the rendering backend used.
@@ -64,7 +71,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
64
71
// updates
65
72
vm . $el = vm . __patch__ ( prevVnode , vnode )
66
73
}
67
- activeInstance = prevActiveInstance
74
+ restoreActiveInstance ( )
68
75
// update __vue__ reference
69
76
if ( prevEl ) {
70
77
prevEl . __vue__ = null
Original file line number Diff line number Diff line change 14
14
import { warn , extend } from 'core/util/index'
15
15
import { addClass , removeClass } from '../class-util'
16
16
import { transitionProps , extractTransitionData } from './transition'
17
+ import { setActiveInstance } from 'core/instance/lifecycle'
17
18
18
19
import {
19
20
hasTransition ,
@@ -36,6 +37,7 @@ export default {
36
37
beforeMount ( ) {
37
38
const update = this . _update
38
39
this . _update = ( vnode , hydrating ) => {
40
+ const restoreActiveInstance = setActiveInstance ( this )
39
41
// force removing pass
40
42
this . __patch__ (
41
43
this . _vnode ,
@@ -44,6 +46,7 @@ export default {
44
46
true // removeOnly (!important, avoids unnecessary moves)
45
47
)
46
48
this . _vnode = this . kept
49
+ restoreActiveInstance ( )
47
50
update . call ( this , vnode , hydrating )
48
51
}
49
52
} ,
You can’t perform that action at this time.
0 commit comments