fix(devtools): send instance to devtools when it's mounted instead of created

This commit is contained in:
Guillaume Chau 2021-01-29 16:48:37 +01:00
parent d224753ff6
commit 4fecb27f86
2 changed files with 9 additions and 6 deletions

View File

@ -56,7 +56,6 @@ import {
markAttrsAccessed markAttrsAccessed
} from './componentRenderUtils' } from './componentRenderUtils'
import { startMeasure, endMeasure } from './profiling' import { startMeasure, endMeasure } from './profiling'
import { devtoolsComponentAdded } from './devtools'
export type Data = Record<string, unknown> export type Data = Record<string, unknown>
@ -486,10 +485,6 @@ export function createComponentInstance(
instance.root = parent ? parent.root : instance instance.root = parent ? parent.root : instance
instance.emit = emit.bind(null, instance) instance.emit = emit.bind(null, instance)
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
devtoolsComponentAdded(instance)
}
return instance return instance
} }

View File

@ -72,7 +72,11 @@ import { createHydrationFunctions, RootHydrateFunction } from './hydration'
import { invokeDirectiveHook } from './directives' import { invokeDirectiveHook } from './directives'
import { startMeasure, endMeasure } from './profiling' import { startMeasure, endMeasure } from './profiling'
import { ComponentPublicInstance } from './componentPublicInstance' import { ComponentPublicInstance } from './componentPublicInstance'
import { devtoolsComponentRemoved, devtoolsComponentUpdated } from './devtools' import {
devtoolsComponentAdded,
devtoolsComponentRemoved,
devtoolsComponentUpdated
} from './devtools'
import { initFeatureFlags } from './featureFlags' import { initFeatureFlags } from './featureFlags'
import { isAsyncWrapper } from './apiAsyncComponent' import { isAsyncWrapper } from './apiAsyncComponent'
@ -1412,6 +1416,10 @@ function baseCreateRenderer(
} }
instance.isMounted = true instance.isMounted = true
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
devtoolsComponentAdded(instance)
}
// #2458: deference mount-only object parameters to prevent memleaks // #2458: deference mount-only object parameters to prevent memleaks
initialVNode = container = anchor = null as any initialVNode = container = anchor = null as any
} else { } else {