From 331b30ebebe7b2ada4c07a4e5df92ab14a515ecd Mon Sep 17 00:00:00 2001 From: Matthieu Riegler Date: Sat, 22 Jun 2024 20:23:21 +0200 Subject: [PATCH] fix(core): support injection of object with null constructor. (#56553) This is debug only code, it shouldn't have any consequences on prod build. fixes #56552 PR Close #56553 --- .../core/src/render3/debug/framework_injector_profiler.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/src/render3/debug/framework_injector_profiler.ts b/packages/core/src/render3/debug/framework_injector_profiler.ts index 8efdfe247cd..bac185dffc6 100644 --- a/packages/core/src/render3/debug/framework_injector_profiler.ts +++ b/packages/core/src/render3/debug/framework_injector_profiler.ts @@ -207,11 +207,13 @@ function handleInstanceCreatedByInjectorEvent( // if our value is an instance of a standalone component, map the injector of that standalone // component to the component class. Otherwise, this event is a noop. - let standaloneComponent: Type | undefined = undefined; + let standaloneComponent: Type | undefined | null = undefined; if (typeof value === 'object') { - standaloneComponent = value?.constructor as Type; + standaloneComponent = value?.constructor as Type | undefined | null; } - if (standaloneComponent === undefined || !isStandaloneComponent(standaloneComponent)) { + + // We want to also cover if `standaloneComponent === null` in addition to `undefined` + if (standaloneComponent == undefined || !isStandaloneComponent(standaloneComponent)) { return; }