diff --git a/modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js b/modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js index 15abf894fc..9de9d0157e 100644 --- a/modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js +++ b/modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js @@ -105,7 +105,8 @@ export class LightDom { var viewInj = this.lightDomView.elementInjectors; this.roots = ListWrapper.map(this.nodes, (n) => - new _Root(n, ListWrapper.find(viewInj, (inj) => inj.forElement(n)))); + new _Root(n, ListWrapper.find(viewInj, + (inj) => isPresent(inj) ? inj.forElement(n) : false))); return this.roots; } diff --git a/modules/angular2/test/core/compiler/shadow_dom/light_dom_spec.js b/modules/angular2/test/core/compiler/shadow_dom/light_dom_spec.js index 449167c4d1..5c2381daf0 100644 --- a/modules/angular2/test/core/compiler/shadow_dom/light_dom_spec.js +++ b/modules/angular2/test/core/compiler/shadow_dom/light_dom_spec.js @@ -180,6 +180,19 @@ export function main() { expect(toHtml(lightDom.expandedDomNodes())).toEqual([""]); }); + + it("should work when the element injector array contains nulls", () => { + var lightDomEl = el("
") + + var lightDomView = new FakeView([null]); + + var lightDom = new LightDom( + lightDomView, + new FakeView(), + lightDomEl); + + expect(toHtml(lightDom.expandedDomNodes())).toEqual([""]); + }); }); describe("redistribute", () => {