fix(di): hostInjector and viewInjector support nested arrays
This commit is contained in:
@ -25,7 +25,6 @@ import {
|
||||
AbstractBindingError,
|
||||
CyclicDependencyError,
|
||||
resolveForwardRef,
|
||||
resolveBindings,
|
||||
VisibilityMetadata,
|
||||
DependencyProvider,
|
||||
self
|
||||
@ -240,9 +239,9 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||
var rb = binding.resolve();
|
||||
var deps = ListWrapper.map(rb.dependencies, DirectiveDependency.createFrom);
|
||||
var resolvedHostInjectables =
|
||||
isPresent(ann.hostInjector) ? resolveBindings(ann.hostInjector) : [];
|
||||
isPresent(ann.hostInjector) ? Injector.resolve(ann.hostInjector) : [];
|
||||
var resolvedViewInjectables = ann instanceof Component && isPresent(ann.viewInjector) ?
|
||||
resolveBindings(ann.viewInjector) :
|
||||
Injector.resolve(ann.viewInjector) :
|
||||
[];
|
||||
var metadata = DirectiveMetadata.create({
|
||||
id: stringify(rb.key.token),
|
||||
|
@ -364,7 +364,6 @@ function _createProtoElementInjector(binderIndex, parentPeiWithDistance, renderE
|
||||
if (directiveBindings.length > 0 || hasVariables) {
|
||||
var directiveVariableBindings =
|
||||
createDirectiveVariableBindings(renderElementBinder, directiveBindings);
|
||||
|
||||
protoElementInjector =
|
||||
ProtoElementInjector.create(parentPeiWithDistance.protoElementInjector, binderIndex,
|
||||
directiveBindings, isPresent(componentDirectiveBinding),
|
||||
|
@ -467,7 +467,7 @@ export class Injector {
|
||||
* `fromResolvedBindings` and `createChildFromResolved`.
|
||||
*/
|
||||
static resolve(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding> {
|
||||
var resolvedBindings = resolveBindings(bindings);
|
||||
var resolvedBindings = _resolveBindings(bindings);
|
||||
var flatten = _flattenBindings(resolvedBindings, new Map());
|
||||
return _createListOfBindings(flatten);
|
||||
}
|
||||
@ -765,7 +765,7 @@ export class Injector {
|
||||
}
|
||||
|
||||
|
||||
export function resolveBindings(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding> {
|
||||
function _resolveBindings(bindings: List<Type | Binding | List<any>>): List<ResolvedBinding> {
|
||||
var resolvedList = ListWrapper.createFixedSize(bindings.length);
|
||||
for (var i = 0; i < bindings.length; i++) {
|
||||
var unresolved = resolveForwardRef(bindings[i]);
|
||||
@ -777,7 +777,7 @@ export function resolveBindings(bindings: List<Type | Binding | List<any>>): Lis
|
||||
} else if (unresolved instanceof Binding) {
|
||||
resolved = unresolved.resolve();
|
||||
} else if (unresolved instanceof List) {
|
||||
resolved = resolveBindings(unresolved);
|
||||
resolved = _resolveBindings(unresolved);
|
||||
} else if (unresolved instanceof BindingBuilder) {
|
||||
throw new InvalidBindingError(unresolved.token);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user