@@ -138,6 +138,7 @@ describe('content projection', () => {
138138 } ) ;
139139
140140 it ( 'should project content with container.' , ( ) => {
141+ /** <div> <ng-content></ng-content></div> */
141142 const Child = createComponent ( 'child' , function ( rf : RenderFlags , ctx : any ) {
142143 if ( rf & RenderFlags . Create ) {
143144 projectionDef ( 0 ) ;
@@ -146,6 +147,16 @@ describe('content projection', () => {
146147 elementEnd ( ) ;
147148 }
148149 } ) ;
150+
151+ /**
152+ * <child>
153+ * (
154+ * % if (value) {
155+ * content
156+ * % }
157+ * )
158+ * </child>
159+ */
149160 const Parent = createComponent ( 'parent' , function ( rf : RenderFlags , ctx : { value : any } ) {
150161 if ( rf & RenderFlags . Create ) {
151162 elementStart ( 0 , 'child' ) ;
@@ -182,12 +193,21 @@ describe('content projection', () => {
182193 } ) ;
183194
184195 it ( 'should project content with container into root' , ( ) => {
196+ /** <ng-content></ng-content> */
185197 const Child = createComponent ( 'child' , function ( rf : RenderFlags , ctx : any ) {
186198 if ( rf & RenderFlags . Create ) {
187199 projectionDef ( 0 ) ;
188200 projection ( 1 , 0 ) ;
189201 }
190202 } ) ;
203+
204+ /**
205+ * <child>
206+ * % if (value) {
207+ * content
208+ * % }
209+ * </child>
210+ */
191211 const Parent = createComponent ( 'parent' , function ( rf : RenderFlags , ctx : { value : any } ) {
192212 if ( rf & RenderFlags . Create ) {
193213 elementStart ( 0 , 'child' ) ;
@@ -222,6 +242,7 @@ describe('content projection', () => {
222242 } ) ;
223243
224244 it ( 'should project content with container and if-else.' , ( ) => {
245+ /** <div><ng-content></ng-content></div> */
225246 const Child = createComponent ( 'child' , function ( rf : RenderFlags , ctx : any ) {
226247 if ( rf & RenderFlags . Create ) {
227248 projectionDef ( 0 ) ;
@@ -230,6 +251,18 @@ describe('content projection', () => {
230251 elementEnd ( ) ;
231252 }
232253 } ) ;
254+
255+ /**
256+ * <child>
257+ * (
258+ * % if (value) {
259+ * content
260+ * % } else {
261+ * else
262+ * % }
263+ * )
264+ * </child>
265+ */
233266 const Parent = createComponent ( 'parent' , function ( rf : RenderFlags , ctx : { value : any } ) {
234267 if ( rf & RenderFlags . Create ) {
235268 elementStart ( 0 , 'child' ) ;
@@ -270,7 +303,7 @@ describe('content projection', () => {
270303 expect ( toHtml ( parent ) ) . toEqual ( '<child><div>(else)</div></child>' ) ;
271304 } ) ;
272305
273- it ( 'should support projection in embedded views' , ( ) => {
306+ it ( 'should support projection into embedded views' , ( ) => {
274307 let childCmptInstance : any ;
275308
276309 /**
@@ -306,9 +339,7 @@ describe('content projection', () => {
306339 }
307340 } ) ;
308341
309- /**
310- * <child>content</child>
311- */
342+ /** <child>content</child> */
312343 const Parent = createComponent ( 'parent' , function ( rf : RenderFlags , ctx : any ) {
313344 if ( rf & RenderFlags . Create ) {
314345 elementStart ( 0 , 'child' ) ;
@@ -383,6 +414,72 @@ describe('content projection', () => {
383414 expect ( toHtml ( parent ) ) . toEqual ( '<child><div></div></child>' ) ;
384415 } ) ;
385416
417+ it ( 'should project containers into embedded views' , ( ) => {
418+ /**
419+ * <div>
420+ * % if (!skipContent) {
421+ * <ng-content></ng-content>
422+ * % }
423+ * </div>
424+ */
425+ const Child = createComponent ( 'child' , function ( rf : RenderFlags , ctx : any ) {
426+ if ( rf & RenderFlags . Create ) {
427+ projectionDef ( 0 ) ;
428+ elementStart ( 1 , 'div' ) ;
429+ { container ( 2 ) ; }
430+ elementEnd ( ) ;
431+ }
432+ if ( rf & RenderFlags . Update ) {
433+ containerRefreshStart ( 2 ) ;
434+ {
435+ if ( ! ctx . skipContent ) {
436+ let rf0 = embeddedViewStart ( 0 ) ;
437+ if ( rf0 & RenderFlags . Create ) {
438+ projection ( 0 , 0 ) ;
439+ }
440+ embeddedViewEnd ( ) ;
441+ }
442+ }
443+ containerRefreshEnd ( ) ;
444+ }
445+ } ) ;
446+
447+ /**
448+ * <child>
449+ * % if (!skipContent) {
450+ * content
451+ * % }
452+ * </child>
453+ */
454+ const Parent = createComponent ( 'parent' , function ( rf : RenderFlags , ctx : any ) {
455+ if ( rf & RenderFlags . Create ) {
456+ elementStart ( 0 , 'child' ) ;
457+ { container ( 1 ) ; }
458+ elementEnd ( ) ;
459+ }
460+ if ( rf & RenderFlags . Update ) {
461+ containerRefreshStart ( 1 ) ;
462+ {
463+ if ( ! ctx . skipContent ) {
464+ let rf0 = embeddedViewStart ( 0 ) ;
465+ if ( rf0 & RenderFlags . Create ) {
466+ text ( 0 , 'content' ) ;
467+ }
468+ embeddedViewEnd ( ) ;
469+ }
470+ }
471+ containerRefreshEnd ( ) ;
472+ }
473+ } , [ Child ] ) ;
474+
475+ const fixture = new ComponentFixture ( Parent ) ;
476+ expect ( fixture . html ) . toEqual ( '<child><div>content</div></child>' ) ;
477+
478+ fixture . component . skipContent = true ;
479+ fixture . update ( ) ;
480+ expect ( fixture . html ) . toEqual ( '<child><div></div></child>' ) ;
481+ } ) ;
482+
386483 it ( 'should support projection in embedded views when ng-content is a root node of an embedded view, with other nodes after' ,
387484 ( ) => {
388485 let childCmptInstance : any ;
0 commit comments