From 4fecb27f8696fdb8f681948543ea81ea62fe43bf Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Fri, 29 Jan 2021 16:48:37 +0100 Subject: [PATCH] fix(devtools): send instance to devtools when it's mounted instead of created --- packages/runtime-core/src/component.ts | 5 ----- packages/runtime-core/src/renderer.ts | 10 +++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/runtime-core/src/component.ts b/packages/runtime-core/src/component.ts index 3904bbb1..494ae41d 100644 --- a/packages/runtime-core/src/component.ts +++ b/packages/runtime-core/src/component.ts @@ -56,7 +56,6 @@ import { markAttrsAccessed } from './componentRenderUtils' import { startMeasure, endMeasure } from './profiling' -import { devtoolsComponentAdded } from './devtools' export type Data = Record @@ -486,10 +485,6 @@ export function createComponentInstance( instance.root = parent ? parent.root : instance instance.emit = emit.bind(null, instance) - if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { - devtoolsComponentAdded(instance) - } - return instance } diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index da86040d..898ae077 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -72,7 +72,11 @@ import { createHydrationFunctions, RootHydrateFunction } from './hydration' import { invokeDirectiveHook } from './directives' import { startMeasure, endMeasure } from './profiling' import { ComponentPublicInstance } from './componentPublicInstance' -import { devtoolsComponentRemoved, devtoolsComponentUpdated } from './devtools' +import { + devtoolsComponentAdded, + devtoolsComponentRemoved, + devtoolsComponentUpdated +} from './devtools' import { initFeatureFlags } from './featureFlags' import { isAsyncWrapper } from './apiAsyncComponent' @@ -1412,6 +1416,10 @@ function baseCreateRenderer( } instance.isMounted = true + if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { + devtoolsComponentAdded(instance) + } + // #2458: deference mount-only object parameters to prevent memleaks initialVNode = container = anchor = null as any } else {