File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ declare interface Component {
15
15
static filter: ( id : string , def ? : Function ) => Function | void ;
16
16
17
17
// public properties
18
- $el: Element | void ;
18
+ $el: any ; // so that we can attach __vue__ to it
19
19
$data: Object ;
20
20
$options: ComponentOptions ;
21
21
$parent: Component | void ;
@@ -72,7 +72,7 @@ declare interface Component {
72
72
) => void ;
73
73
// rendering
74
74
_render : ( ) => VNode ;
75
- __patch__ : ( a : Element | VNode | void , b : VNode ) => Element ;
75
+ __patch__ : ( a : Element | VNode | void , b : VNode ) => any ;
76
76
// renderElementWithChildren
77
77
_h : (
78
78
vnode ? : VNode ,
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
68
68
if ( vm . _isMounted ) {
69
69
callHook ( vm , 'beforeUpdate' )
70
70
}
71
+ const prevEl = vm . $el
71
72
if ( ! vm . _vnode ) {
72
73
// Vue.prototype.__patch__ is injected in entry points
73
74
// based on the rendering backend used.
@@ -76,6 +77,13 @@ export function lifecycleMixin (Vue: Class<Component>) {
76
77
vm . $el = vm . __patch__ ( vm . _vnode , vnode )
77
78
}
78
79
vm . _vnode = vnode
80
+ // update __vue__ reference
81
+ if ( prevEl ) {
82
+ prevEl . __vue__ = null
83
+ }
84
+ if ( vm . $el ) {
85
+ vm . $el . __vue__ = vm
86
+ }
79
87
// update parent vnode element after patch
80
88
const parentNode = vm . $options . _parentVnode
81
89
if ( parentNode ) {
@@ -166,6 +174,8 @@ export function lifecycleMixin (Vue: Class<Component>) {
166
174
callHook ( vm , 'destroyed' )
167
175
// turn off all instance listeners.
168
176
vm . $off ( )
177
+ // remove __vue__ reference
178
+ vm . $el . __vue__ = null
169
179
}
170
180
}
171
181
You can’t perform that action at this time.
0 commit comments