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
This commit is contained in:
Matthieu Riegler 2024-06-22 20:23:21 +02:00 committed by Jessica Janiuk
parent 4343cd2ceb
commit 331b30ebeb

View file

@ -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<unknown> | undefined = undefined;
let standaloneComponent: Type<unknown> | undefined | null = undefined;
if (typeof value === 'object') {
standaloneComponent = value?.constructor as Type<unknown>;
standaloneComponent = value?.constructor as Type<unknown> | 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;
}