feat: expose __vue__ in dev mode

This commit is contained in:
Evan You 2018-10-04 16:35:07 -04:00
parent 3c49b30e17
commit 65033cec9d

View File

@ -1200,6 +1200,10 @@ export function createRenderer(options: RendererOptions) {
instance.$vnode = renderInstanceRoot(instance) as MountedVNode instance.$vnode = renderInstanceRoot(instance) as MountedVNode
mount(instance.$vnode, container, instance, isSVG, endNode) mount(instance.$vnode, container, instance, isSVG, endNode)
parentVNode.el = instance.$vnode.el parentVNode.el = instance.$vnode.el
if (__DEV__) {
// expose __vue__ for devtools
;(parentVNode.el as any).__vue__ = instance
}
instance._mounted = true instance._mounted = true
mountComponentInstanceCallbacks(instance, parentVNode.ref) mountComponentInstanceCallbacks(instance, parentVNode.ref)
} }
@ -1242,6 +1246,11 @@ export function createRenderer(options: RendererOptions) {
patch(prevVNode, nextVNode, container, instance, isSVG) patch(prevVNode, nextVNode, container, instance, isSVG)
const el = nextVNode.el as RenderNode const el = nextVNode.el as RenderNode
if (__DEV__) {
// expose __vue__ for devtools
;(el as any).__vue__ = instance
}
// recursively update parentVNode el for nested HOCs // recursively update parentVNode el for nested HOCs
if ((nextVNode.flags & VNodeFlags.PORTAL) === 0) { if ((nextVNode.flags & VNodeFlags.PORTAL) === 0) {
let vnode = instance.$parentVNode let vnode = instance.$parentVNode