feat(ElementInjector): throw if multiple directives define the same host injectable

relates to #2015
This commit is contained in:
Victor Berchet
2015-06-02 17:47:14 +02:00
parent 309ef0f354
commit 6a6b43de07
2 changed files with 21 additions and 2 deletions

View File

@ -466,8 +466,14 @@ export class ProtoElementInjector {
private static _createHostInjectorBindingData(bindings: List<ResolvedBinding>,
bd: List<BindingData>) {
var visitedIds: Map<number, boolean> = MapWrapper.create();
ListWrapper.forEach(bindings, b => {
ListWrapper.forEach(b.resolvedHostInjectables, b => {
if (MapWrapper.contains(visitedIds, b.key.id)) {
throw new BaseException(
`Multiple directives defined the same host injectable: "${stringify(b.key.token)}"`);
}
MapWrapper.set(visitedIds, b.key.id, true);
ListWrapper.push(bd, new BindingData(ProtoElementInjector._createBinding(b), LIGHT_DOM));
});
});