fix(core): support nested arrays of providers in EnvironmentInjector (#45789)

This commit updates the `EnvironmentInjector` logic to support arrays of providers as an argument(for example, when an injector is created via `createEnvironmentInjector` function).

PR Close #45789
This commit is contained in:
Andrew Kushnir
2022-04-27 18:17:25 -07:00
committed by Dylan Hunn
parent 29417935de
commit 4e413d9240
2 changed files with 27 additions and 4 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ import {Type} from '../interface/type';
import {getComponentDef} from '../render3/definition';
import {FactoryFn, getFactoryDef} from '../render3/definition_factory';
import {throwCyclicDependencyError, throwInvalidProviderError, throwMixedMultiProviderError} from '../render3/errors_di';
import {flatten, newArray} from '../util/array_utils';
import {deepForEach, flatten, newArray} from '../util/array_utils';
import {EMPTY_ARRAY} from '../util/empty';
import {stringify} from '../util/stringify';
@@ -125,9 +125,9 @@ export class R3Injector extends EnvironmentInjector {
readonly scopes: Set<InjectorScope>) {
super();
// Start off by creating Records for every provider.
for (const provider of providers) {
deepForEach(providers, provider => {
this.processProvider(provider as SingleProvider);
}
});
// Make sure the INJECTOR token provides this injector.
this.records.set(INJECTOR, makeRecord(undefined, this));