diff --git a/modules/@angular/compiler/src/view_compiler/view_builder.ts b/modules/@angular/compiler/src/view_compiler/view_builder.ts index 7070be0c93..1548edac19 100644 --- a/modules/@angular/compiler/src/view_compiler/view_builder.ts +++ b/modules/@angular/compiler/src/view_compiler/view_builder.ts @@ -78,7 +78,7 @@ class ViewBuilderVisitor implements TemplateAstVisitor { } private _getParentRenderNode(parent: CompileElement): o.Expression { - parent = _getOuterContainerParentOrSelf(parent); + parent = _getOuterContainerParentOrSelf(parent); if (this._isRootNode(parent)) { if (this.view.viewType === ViewType.COMPONENT) { return parentRenderNodeVar; diff --git a/modules/@angular/core/test/linker/ng_container_integration_spec.ts b/modules/@angular/core/test/linker/ng_container_integration_spec.ts index 2961ead31e..2b221d402d 100644 --- a/modules/@angular/core/test/linker/ng_container_integration_spec.ts +++ b/modules/@angular/core/test/linker/ng_container_integration_spec.ts @@ -33,7 +33,6 @@ function declareTests({useJit}: {useJit: boolean}) { tcb.overrideTemplate(MyComp, '

') .createAsync(MyComp) .then((fixture) => { - fixture.detectChanges(); const el = fixture.debugElement.nativeElement; @@ -46,6 +45,30 @@ function declareTests({useJit}: {useJit: boolean}) { }); })); + it('should support nesting', + inject( + [TestComponentBuilder, AsyncTestCompleter], + (tcb: TestComponentBuilder, async: AsyncTestCompleter) => { + tcb.overrideTemplate( + MyComp, + '12') + .createAsync(MyComp) + .then((fixture) => { + fixture.detectChanges(); + + const el = fixture.debugElement.nativeElement; + const children = getDOM().childNodes(el); + expect(children.length).toBe(5); + expect(getDOM().isCommentNode(children[0])).toBe(true); + expect(children[1]).toHaveText('1'); + expect(getDOM().isCommentNode(children[2])).toBe(true); + expect(getDOM().isCommentNode(children[3])).toBe(true); + expect(children[4]).toHaveText('2'); + + async.done(); + }); + })); + it('should group inner nodes', inject( [TestComponentBuilder, AsyncTestCompleter], @@ -87,8 +110,10 @@ function declareTests({useJit}: {useJit: boolean}) { .createAsync(MyComp) .then((fixture) => { fixture.detectChanges(); + const el = fixture.debugElement.nativeElement; expect(el).toHaveText('SIMPLE(12)'); + async.done(); }); })); @@ -102,9 +127,11 @@ function declareTests({useJit}: {useJit: boolean}) { .createAsync(MyComp) .then((fixture) => { fixture.detectChanges(); + const dir = fixture.debugElement.children[0].injector.get(TextDirective); expect(dir).toBeAnInstanceOf(TextDirective); expect(dir.text).toEqual('container'); + async.done(); }); })); @@ -118,9 +145,7 @@ function declareTests({useJit}: {useJit: boolean}) { tcb.overrideTemplate(MyComp, template).createAsync(MyComp).then((view) => { view.detectChanges(); - var q = view.debugElement.children[0].references['q']; - view.detectChanges(); expect(q.textDirChildren.length).toEqual(1); @@ -138,9 +163,7 @@ function declareTests({useJit}: {useJit: boolean}) { tcb.overrideTemplate(MyComp, template).createAsync(MyComp).then((view) => { view.detectChanges(); - var q = view.debugElement.children[0].references['q']; - view.detectChanges(); expect(q.textDirChildren.length).toEqual(1);