From 29f5ee0c293e8af4f4e8daf31ac7fb02e4783ec3 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Fri, 20 Feb 2015 15:19:51 -0800 Subject: [PATCH] fix(shadow_dom_emulation): handle the case when the array of element injectors has nulls --- .../core/compiler/shadow_dom_emulation/light_dom.js | 3 ++- .../test/core/compiler/shadow_dom/light_dom_spec.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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", () => {