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 {
1515 static filter: ( id : string , def ? : Function ) => Function | void ;
1616
1717 // public properties
18- $el: Element | void ;
18+ $el: any ; // so that we can attach __vue__ to it
1919 $data: Object ;
2020 $options: ComponentOptions ;
2121 $parent: Component | void ;
@@ -72,7 +72,7 @@ declare interface Component {
7272 ) => void ;
7373 // rendering
7474 _render : ( ) => VNode ;
75- __patch__ : ( a : Element | VNode | void , b : VNode ) => Element ;
75+ __patch__ : ( a : Element | VNode | void , b : VNode ) => any ;
7676 // renderElementWithChildren
7777 _h : (
7878 vnode ? : VNode ,
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
6868 if ( vm . _isMounted ) {
6969 callHook ( vm , 'beforeUpdate' )
7070 }
71+ const prevEl = vm . $el
7172 if ( ! vm . _vnode ) {
7273 // Vue.prototype.__patch__ is injected in entry points
7374 // based on the rendering backend used.
@@ -76,6 +77,13 @@ export function lifecycleMixin (Vue: Class<Component>) {
7677 vm . $el = vm . __patch__ ( vm . _vnode , vnode )
7778 }
7879 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+ }
7987 // update parent vnode element after patch
8088 const parentNode = vm . $options . _parentVnode
8189 if ( parentNode ) {
@@ -166,6 +174,8 @@ export function lifecycleMixin (Vue: Class<Component>) {
166174 callHook ( vm , 'destroyed' )
167175 // turn off all instance listeners.
168176 vm . $off ( )
177+ // remove __vue__ reference
178+ vm . $el . __vue__ = null
169179 }
170180}
171181
You can’t perform that action at this time.
0 commit comments