11import { describe , beforeEach , it , expect , iit , ddescribe } from 'test_lib/test_lib' ;
2- import { ListWrapper , List } from 'facade/collection' ;
2+ import { ListWrapper , List , MapWrapper } from 'facade/collection' ;
33import { DOM } from 'facade/dom' ;
44import { isPresent , NumberWrapper , StringWrapper } from 'facade/lang' ;
55
@@ -10,14 +10,27 @@ import {CompileControl} from 'core/compiler/pipeline/compile_control';
1010
1111export function main ( ) {
1212 describe ( 'compile_pipeline' , ( ) => {
13- it ( 'should walk the tree in depth first order including template contents' , ( ) => {
14- var element = createElement ( '<div id="1"><template id="2"><span id="3"></span></template></div>' ) ;
13+ describe ( 'children compilation' , ( ) => {
14+ it ( 'should walk the tree in depth first order including template contents' , ( ) => {
15+ var element = createElement ( '<div id="1"><template id="2"><span id="3"></span></template></div>' ) ;
1516
16- var step0Log = [ ] ;
17- var results = new CompilePipeline ( [ createLoggerStep ( step0Log ) ] ) . process ( element ) ;
17+ var step0Log = [ ] ;
18+ var results = new CompilePipeline ( [ createLoggerStep ( step0Log ) ] ) . process ( element ) ;
19+
20+ expect ( step0Log ) . toEqual ( [ '1' , '1<2' , '2<3' ] ) ;
21+ expect ( resultIdLog ( results ) ) . toEqual ( [ '1' , '2' , '3' ] ) ;
22+ } ) ;
23+
24+ it ( 'should stop walking the tree when compileChildren is false' , ( ) => {
25+ var element = createElement ( '<div id="1"><template id="2" ignore-children><span id="3"></span></template></div>' ) ;
26+
27+ var step0Log = [ ] ;
28+ var pipeline = new CompilePipeline ( [ new IgnoreChildrenStep ( ) , createLoggerStep ( step0Log ) ] ) ;
29+ var results = pipeline . process ( element ) ;
1830
19- expect ( step0Log ) . toEqual ( [ '1' , '1<2' , '2<3' ] ) ;
20- expect ( resultIdLog ( results ) ) . toEqual ( [ '1' , '2' , '3' ] ) ;
31+ expect ( step0Log ) . toEqual ( [ '1' , '1<2' ] ) ;
32+ expect ( resultIdLog ( results ) ) . toEqual ( [ '1' , '2' ] ) ;
33+ } ) ;
2134 } ) ;
2235
2336 describe ( 'control.addParent' , ( ) => {
@@ -118,6 +131,15 @@ class MockStep extends CompileStep {
118131 }
119132}
120133
134+ class IgnoreChildrenStep extends CompileStep {
135+ process ( parent :CompileElement , current :CompileElement , control :CompileControl ) {
136+ var attributeMap = DOM . attributeMap ( current . element ) ;
137+ if ( MapWrapper . contains ( attributeMap , 'ignore-children' ) ) {
138+ current . compileChildren = false ;
139+ }
140+ }
141+ }
142+
121143function logEntry ( log , parent , current ) {
122144 var parentId = '' ;
123145 if ( isPresent ( parent ) ) {
0 commit comments