fix(devtools): expose root instance
related to https://github.com/vuejs/vue-devtools/issues/1376
This commit is contained in:
parent
ade9bd9daa
commit
2b52d5d7c5
@ -2,7 +2,8 @@ import {
|
|||||||
ConcreteComponent,
|
ConcreteComponent,
|
||||||
Data,
|
Data,
|
||||||
validateComponentName,
|
validateComponentName,
|
||||||
Component
|
Component,
|
||||||
|
ComponentInternalInstance
|
||||||
} from './component'
|
} from './component'
|
||||||
import {
|
import {
|
||||||
ComponentOptions,
|
ComponentOptions,
|
||||||
@ -46,6 +47,7 @@ export interface App<HostElement = any> {
|
|||||||
_props: Data | null
|
_props: Data | null
|
||||||
_container: HostElement | null
|
_container: HostElement | null
|
||||||
_context: AppContext
|
_context: AppContext
|
||||||
|
_instance: ComponentInternalInstance | null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* v2 compat only
|
* v2 compat only
|
||||||
@ -186,6 +188,7 @@ export function createAppAPI<HostElement>(
|
|||||||
_props: rootProps,
|
_props: rootProps,
|
||||||
_container: null,
|
_container: null,
|
||||||
_context: context,
|
_context: context,
|
||||||
|
_instance: null,
|
||||||
|
|
||||||
version,
|
version,
|
||||||
|
|
||||||
@ -296,6 +299,7 @@ export function createAppAPI<HostElement>(
|
|||||||
;(rootContainer as any).__vue_app__ = app
|
;(rootContainer as any).__vue_app__ = app
|
||||||
|
|
||||||
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
||||||
|
app._instance = vnode.component
|
||||||
devtoolsInitApp(app, version)
|
devtoolsInitApp(app, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +318,7 @@ export function createAppAPI<HostElement>(
|
|||||||
if (isMounted) {
|
if (isMounted) {
|
||||||
render(null, app._container)
|
render(null, app._container)
|
||||||
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
||||||
|
app._instance = null
|
||||||
devtoolsUnmountApp(app)
|
devtoolsUnmountApp(app)
|
||||||
}
|
}
|
||||||
delete app._container.__vue_app__
|
delete app._container.__vue_app__
|
||||||
|
Loading…
Reference in New Issue
Block a user