@@ -18,7 +18,7 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
1818
1919import { PromiseWrapper , EventEmitter , ObservableWrapper } from 'angular2/src/core/facade/async' ;
2020
21- import { Injectable , NgFor } from 'angular2/core' ;
21+ import { Injectable , NgFor , NgIf } from 'angular2/core' ;
2222import { By , Scope } from 'angular2/src/core/debug' ;
2323
2424import {
@@ -61,14 +61,24 @@ class ChildComp {
6161 constructor ( ) { this . childBinding = 'Original' ; }
6262}
6363
64+ @Component ( { selector : 'cond-content-comp' , viewProviders : [ Logger ] } )
65+ @View ( {
66+ template : `<div class="child" message="child" *ng-if="false"><ng-content></ng-content></div>` ,
67+ directives : [ NgIf , MessageDir ]
68+ } )
69+ @Injectable ( )
70+ class ConditionalContentComp {
71+ }
72+
6473@Component ( { selector : 'parent-comp' , viewProviders : [ Logger ] } )
6574@View ( {
6675 template : `<div class="parent" message="parent">
6776 <span class="parentnested" message="nestedparent">Parent</span>
6877 </div>
6978 <span class="parent" [inner-html]="parentBinding"></span>
70- <child-comp class="child-comp-class"></child-comp>` ,
71- directives : [ ChildComp , MessageDir ]
79+ <child-comp class="child-comp-class"></child-comp>
80+ <cond-content-comp class="cond-content-comp-class"></cond-content-comp>` ,
81+ directives : [ ChildComp , MessageDir , ConditionalContentComp ]
7282} )
7383@Injectable ( )
7484class ParentComp {
@@ -135,12 +145,14 @@ export function main() {
135145 expect ( childEls . length ) . toEqual ( 0 ) ;
136146
137147 var rootCompChildren = rootTestComponent . debugElement . componentViewChildren ;
138- // The root component has 3 elements in its shadow view.
139- expect ( rootCompChildren . length ) . toEqual ( 3 ) ;
148+ // The root component has 4 elements in its shadow view.
149+ expect ( rootCompChildren . length ) . toEqual ( 4 ) ;
140150 expect ( DOM . hasClass ( rootCompChildren [ 0 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
141151 expect ( DOM . hasClass ( rootCompChildren [ 1 ] . nativeElement , 'parent' ) ) . toBe ( true ) ;
142152 expect ( DOM . hasClass ( rootCompChildren [ 2 ] . nativeElement , 'child-comp-class' ) )
143153 . toBe ( true ) ;
154+ expect ( DOM . hasClass ( rootCompChildren [ 3 ] . nativeElement , 'cond-content-comp-class' ) )
155+ . toBe ( true ) ;
144156
145157 var nested = rootCompChildren [ 0 ] . children ;
146158 expect ( nested . length ) . toEqual ( 1 ) ;
@@ -158,6 +170,14 @@ export function main() {
158170 expect ( childNested . length ) . toEqual ( 1 ) ;
159171 expect ( DOM . hasClass ( childNested [ 0 ] . nativeElement , 'childnested' ) ) . toBe ( true ) ;
160172
173+ var conditionalContentComp = rootCompChildren [ 3 ] ;
174+ expect ( conditionalContentComp . children . length ) . toEqual ( 0 ) ;
175+
176+ expect ( conditionalContentComp . componentViewChildren . length ) . toEqual ( 1 ) ;
177+ var ngIfWithProjectedNgContent = conditionalContentComp . componentViewChildren [ 0 ] ;
178+ expect ( ngIfWithProjectedNgContent . children . length ) . toBe ( 0 ) ;
179+ expect ( ngIfWithProjectedNgContent . componentViewChildren . length ) . toBe ( 0 ) ;
180+
161181 async . done ( ) ;
162182 } ) ;
163183 } ) ) ;
0 commit comments