Skip to content

Commit 29f5ee0

Browse files
committed
fix(shadow_dom_emulation): handle the case when the array of element injectors has nulls
1 parent 7aa031b commit 29f5ee0

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

modules/angular2/src/core/compiler/shadow_dom_emulation/light_dom.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export class LightDom {
105105

106106
var viewInj = this.lightDomView.elementInjectors;
107107
this.roots = ListWrapper.map(this.nodes, (n) =>
108-
new _Root(n, ListWrapper.find(viewInj, (inj) => inj.forElement(n))));
108+
new _Root(n, ListWrapper.find(viewInj,
109+
(inj) => isPresent(inj) ? inj.forElement(n) : false)));
109110

110111
return this.roots;
111112
}

modules/angular2/test/core/compiler/shadow_dom/light_dom_spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ export function main() {
180180

181181
expect(toHtml(lightDom.expandedDomNodes())).toEqual(["<a></a>"]);
182182
});
183+
184+
it("should work when the element injector array contains nulls", () => {
185+
var lightDomEl = el("<div><a></a></div>")
186+
187+
var lightDomView = new FakeView([null]);
188+
189+
var lightDom = new LightDom(
190+
lightDomView,
191+
new FakeView(),
192+
lightDomEl);
193+
194+
expect(toHtml(lightDom.expandedDomNodes())).toEqual(["<a></a>"]);
195+
});
183196
});
184197

185198
describe("redistribute", () => {

0 commit comments

Comments
 (0)