| 
									
										
										
										
											2015-03-16 14:44:14 -07:00
										 |  |  | import {Injectable} from 'angular2/di'; | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  | import {Type, isBlank, isPresent, BaseException, normalizeBlank, stringify} from 'angular2/src/facade/lang'; | 
					
						
							| 
									
										
										
										
											2015-02-05 13:08:05 -08:00
										 |  |  | import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  | import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection'; | 
					
						
							| 
									
										
										
										
											2014-11-11 17:33:47 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-20 12:07:48 -08:00
										 |  |  | import {DirectiveMetadataReader} from './directive_metadata_reader'; | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  | import {Component, Viewport, DynamicComponent, Decorator} from '../annotations/annotations'; | 
					
						
							| 
									
										
										
										
											2014-11-11 17:33:47 -08:00
										 |  |  | import {ProtoView} from './view'; | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  | import {DirectiveBinding} from './element_injector'; | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  | import {TemplateResolver} from './template_resolver'; | 
					
						
							|  |  |  | import {Template} from '../annotations/template'; | 
					
						
							| 
									
										
										
										
											2015-02-24 16:05:45 +01:00
										 |  |  | import {ComponentUrlMapper} from './component_url_mapper'; | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  | import {ProtoViewFactory} from './proto_view_factory'; | 
					
						
							| 
									
										
										
										
											2015-04-02 09:52:00 -07:00
										 |  |  | import {UrlResolver} from 'angular2/src/services/url_resolver'; | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | import * as renderApi from 'angular2/src/render/api'; | 
					
						
							| 
									
										
										
										
											2015-02-06 15:41:02 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-02 13:21:39 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Cache that stores the ProtoView of the template of a component. | 
					
						
							|  |  |  |  * Used to prevent duplicate work and resolve cyclic dependencies. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-03-16 14:44:14 -07:00
										 |  |  | @Injectable() | 
					
						
							| 
									
										
										
										
											2014-12-02 13:21:39 -08:00
										 |  |  | export class CompilerCache { | 
					
						
							|  |  |  |   _cache:Map; | 
					
						
							|  |  |  |   constructor() { | 
					
						
							|  |  |  |     this._cache = MapWrapper.create(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   set(component:Type, protoView:ProtoView) { | 
					
						
							|  |  |  |     MapWrapper.set(this._cache, component, protoView); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   get(component:Type):ProtoView { | 
					
						
							|  |  |  |     var result = MapWrapper.get(this._cache, component); | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  |     return normalizeBlank(result); | 
					
						
							| 
									
										
										
										
											2014-12-02 13:21:39 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   clear() { | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  |     MapWrapper.clear(this._cache); | 
					
						
							| 
									
										
										
										
											2014-12-22 17:50:10 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-12-02 13:21:39 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-07 20:54:20 -07:00
										 |  |  | export class Compiler { | 
					
						
							| 
									
										
										
										
											2014-11-20 12:07:48 -08:00
										 |  |  |   _reader: DirectiveMetadataReader; | 
					
						
							| 
									
										
										
										
											2014-12-02 13:21:39 -08:00
										 |  |  |   _compilerCache:CompilerCache; | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  |   _compiling:Map<Type, Promise>; | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  |   _templateResolver: TemplateResolver; | 
					
						
							| 
									
										
										
										
											2015-02-24 16:05:45 +01:00
										 |  |  |   _componentUrlMapper: ComponentUrlMapper; | 
					
						
							|  |  |  |   _urlResolver: UrlResolver; | 
					
						
							|  |  |  |   _appUrl: string; | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |   _renderer: renderApi.Renderer; | 
					
						
							|  |  |  |   _protoViewFactory:ProtoViewFactory; | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |   constructor(reader: DirectiveMetadataReader, | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  |               cache:CompilerCache, | 
					
						
							| 
									
										
										
										
											2015-02-24 16:05:45 +01:00
										 |  |  |               templateResolver: TemplateResolver, | 
					
						
							|  |  |  |               componentUrlMapper: ComponentUrlMapper, | 
					
						
							| 
									
										
										
										
											2015-03-02 15:02:48 +01:00
										 |  |  |               urlResolver: UrlResolver, | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |               renderer: renderApi.Renderer, | 
					
						
							|  |  |  |               protoViewFactory: ProtoViewFactory) { | 
					
						
							| 
									
										
										
										
											2014-11-20 12:07:48 -08:00
										 |  |  |     this._reader = reader; | 
					
						
							| 
									
										
										
										
											2014-12-02 13:21:39 -08:00
										 |  |  |     this._compilerCache = cache; | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  |     this._compiling = MapWrapper.create(); | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  |     this._templateResolver = templateResolver; | 
					
						
							| 
									
										
										
										
											2015-02-24 16:05:45 +01:00
										 |  |  |     this._componentUrlMapper = componentUrlMapper; | 
					
						
							|  |  |  |     this._urlResolver = urlResolver; | 
					
						
							|  |  |  |     this._appUrl = urlResolver.resolve(null, './'); | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |     this._renderer = renderer; | 
					
						
							|  |  |  |     this._protoViewFactory = protoViewFactory; | 
					
						
							| 
									
										
										
										
											2014-09-19 16:38:37 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-07 20:54:20 -07:00
										 |  |  |   _bindDirective(directiveTypeOrBinding) { | 
					
						
							|  |  |  |     if (directiveTypeOrBinding instanceof DirectiveBinding) { | 
					
						
							|  |  |  |       return directiveTypeOrBinding; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     var meta = this._reader.read(directiveTypeOrBinding); | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |     return DirectiveBinding.createFromType(meta.type, meta.annotation); | 
					
						
							| 
									
										
										
										
											2014-09-19 23:03:36 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |   // Create a rootView as if the compiler encountered <rootcmp></rootcmp>.
 | 
					
						
							|  |  |  |   // Used for bootstrapping.
 | 
					
						
							| 
									
										
										
										
											2015-04-07 20:54:20 -07:00
										 |  |  |   compileRoot(elementOrSelector, componentTypeOrBinding:any):Promise<ProtoView> { | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |     return this._renderer.createRootProtoView(elementOrSelector, 'root').then( (rootRenderPv) => { | 
					
						
							| 
									
										
										
										
											2015-04-07 20:54:20 -07:00
										 |  |  |       return this._compileNestedProtoViews(null, rootRenderPv, [this._bindDirective(componentTypeOrBinding)], true); | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  |   compile(component: Type):Promise<ProtoView> { | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |     var protoView = this._compile(this._bindDirective(component)); | 
					
						
							| 
									
										
										
										
											2015-02-06 08:57:49 +01:00
										 |  |  |     return PromiseWrapper.isPromise(protoView) ? protoView : PromiseWrapper.resolve(protoView); | 
					
						
							| 
									
										
										
										
											2014-11-11 17:33:47 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2014-09-19 16:38:37 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-06 08:57:49 +01:00
										 |  |  |   // TODO(vicb): union type return ProtoView or Promise<ProtoView>
 | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |   _compile(componentBinding: DirectiveBinding) { | 
					
						
							|  |  |  |     var component = componentBinding.key.token; | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  |     var protoView = this._compilerCache.get(component); | 
					
						
							| 
									
										
										
										
											2015-02-06 08:57:49 +01:00
										 |  |  |     if (isPresent(protoView)) { | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  |       // The component has already been compiled into a ProtoView,
 | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |       // returns a plain ProtoView, not wrapped inside of a Promise.
 | 
					
						
							|  |  |  |       // Needed for recursive components.
 | 
					
						
							| 
									
										
										
										
											2015-02-06 08:57:49 +01:00
										 |  |  |       return protoView; | 
					
						
							| 
									
										
										
										
											2014-12-02 13:21:39 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  |     var pvPromise = MapWrapper.get(this._compiling, component); | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  |     if (isPresent(pvPromise)) { | 
					
						
							|  |  |  |       // The component is already being compiled, attach to the existing Promise
 | 
					
						
							|  |  |  |       // instead of re-compiling the component.
 | 
					
						
							|  |  |  |       // It happens when a template references a component multiple times.
 | 
					
						
							|  |  |  |       return pvPromise; | 
					
						
							| 
									
										
										
										
											2014-11-11 17:33:47 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-12-02 13:21:39 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  |     var template = this._templateResolver.resolve(component); | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |     var directives = ListWrapper.map( | 
					
						
							|  |  |  |       this._flattenDirectives(template), | 
					
						
							|  |  |  |       (directive) => this._bindDirective(directive) | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |     var renderTemplate = this._buildRenderTemplate(component, template, directives); | 
					
						
							|  |  |  |     pvPromise = this._renderer.compile(renderTemplate).then( (renderPv) => { | 
					
						
							|  |  |  |       return this._compileNestedProtoViews(componentBinding, renderPv, directives, true); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MapWrapper.set(this._compiling, component, pvPromise); | 
					
						
							|  |  |  |     return pvPromise; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |   // TODO(tbosch): union type return ProtoView or Promise<ProtoView>
 | 
					
						
							|  |  |  |   _compileNestedProtoViews(componentBinding, renderPv, directives, isComponentRootView) { | 
					
						
							|  |  |  |     var nestedPVPromises = []; | 
					
						
							|  |  |  |     var protoView = this._protoViewFactory.createProtoView(componentBinding, renderPv, directives); | 
					
						
							|  |  |  |     if (isComponentRootView && isPresent(componentBinding)) { | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |       // Populate the cache before compiling the nested components,
 | 
					
						
							|  |  |  |       // so that components can reference themselves in their template.
 | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |       var component = componentBinding.key.token; | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |       this._compilerCache.set(component, protoView); | 
					
						
							|  |  |  |       MapWrapper.delete(this._compiling, component); | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |     var binderIndex = 0; | 
					
						
							|  |  |  |     ListWrapper.forEach(protoView.elementBinders, (elementBinder) => { | 
					
						
							|  |  |  |       var nestedComponent = elementBinder.componentDirective; | 
					
						
							|  |  |  |       var nestedRenderProtoView = renderPv.elementBinders[binderIndex].nestedProtoView; | 
					
						
							|  |  |  |       var elementBinderDone = (nestedPv) => { | 
					
						
							|  |  |  |         elementBinder.nestedProtoView = nestedPv; | 
					
						
							|  |  |  |         // Can't set the parentProtoView for components,
 | 
					
						
							|  |  |  |         // as their ProtoView might be used in multiple other components.
 | 
					
						
							|  |  |  |         nestedPv.parentProtoView = isPresent(nestedComponent) ? null : protoView; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       var nestedCall = null; | 
					
						
							|  |  |  |       if (isPresent(nestedComponent)) { | 
					
						
							|  |  |  |         if (!(nestedComponent.annotation instanceof DynamicComponent)) { | 
					
						
							|  |  |  |           nestedCall = this._compile(nestedComponent); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } else if (isPresent(nestedRenderProtoView)) { | 
					
						
							|  |  |  |         nestedCall = this._compileNestedProtoViews(componentBinding, nestedRenderProtoView, directives, false); | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |       if (PromiseWrapper.isPromise(nestedCall)) { | 
					
						
							|  |  |  |         ListWrapper.push(nestedPVPromises, nestedCall.then(elementBinderDone)); | 
					
						
							|  |  |  |       } else if (isPresent(nestedCall)) { | 
					
						
							|  |  |  |         elementBinderDone(nestedCall); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       binderIndex++; | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     var protoViewDone = (_) => { | 
					
						
							|  |  |  |       var childComponentRenderPvRefs = []; | 
					
						
							|  |  |  |       ListWrapper.forEach(protoView.elementBinders, (eb) => { | 
					
						
							|  |  |  |         if (isPresent(eb.componentDirective)) { | 
					
						
							|  |  |  |           var componentPv = eb.nestedProtoView; | 
					
						
							|  |  |  |           ListWrapper.push(childComponentRenderPvRefs, isPresent(componentPv) ? componentPv.render : null); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |       this._renderer.mergeChildComponentProtoViews(protoView.render, childComponentRenderPvRefs); | 
					
						
							|  |  |  |       return protoView; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     if (nestedPVPromises.length > 0) { | 
					
						
							|  |  |  |       return PromiseWrapper.all(nestedPVPromises).then(protoViewDone); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       return protoViewDone(null); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |   _buildRenderTemplate(component, template, directives) { | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |     var componentUrl = this._urlResolver.resolve( | 
					
						
							|  |  |  |         this._appUrl, this._componentUrlMapper.getUrl(component) | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     var templateAbsUrl = null; | 
					
						
							|  |  |  |     if (isPresent(template.url)) { | 
					
						
							|  |  |  |       templateAbsUrl = this._urlResolver.resolve(componentUrl, template.url); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       // Note: If we have an inline template, we also need to send
 | 
					
						
							|  |  |  |       // the url for the component to the renderer so that it
 | 
					
						
							|  |  |  |       // is able to resolve urls in stylesheets.
 | 
					
						
							|  |  |  |       templateAbsUrl = componentUrl; | 
					
						
							| 
									
										
										
										
											2015-02-06 08:57:49 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-07 17:24:09 -07:00
										 |  |  |     return new renderApi.Template({ | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |       componentId: stringify(component), | 
					
						
							|  |  |  |       absUrl: templateAbsUrl, | 
					
						
							|  |  |  |       inline: template.inline, | 
					
						
							|  |  |  |       directives: ListWrapper.map(directives, this._buildRenderDirective) | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-01-30 09:43:21 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |   _buildRenderDirective(directiveBinding) { | 
					
						
							|  |  |  |     var ann = directiveBinding.annotation; | 
					
						
							|  |  |  |     var renderType; | 
					
						
							|  |  |  |     var compileChildren = true; | 
					
						
							|  |  |  |     if ((ann instanceof Component) || (ann instanceof DynamicComponent)) { | 
					
						
							|  |  |  |       renderType = renderApi.DirectiveMetadata.COMPONENT_TYPE; | 
					
						
							|  |  |  |     } else if (ann instanceof Viewport) { | 
					
						
							|  |  |  |       renderType = renderApi.DirectiveMetadata.VIEWPORT_TYPE; | 
					
						
							|  |  |  |     } else if (ann instanceof Decorator) { | 
					
						
							|  |  |  |       renderType = renderApi.DirectiveMetadata.DECORATOR_TYPE; | 
					
						
							|  |  |  |       compileChildren = ann.compileChildren; | 
					
						
							| 
									
										
										
										
											2015-02-06 08:57:49 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-02 14:40:49 -07:00
										 |  |  |     var setters = []; | 
					
						
							|  |  |  |     var readAttributes = []; | 
					
						
							|  |  |  |     ListWrapper.forEach(directiveBinding.dependencies, (dep) => { | 
					
						
							|  |  |  |       if (isPresent(dep.propSetterName)) { | 
					
						
							|  |  |  |         ListWrapper.push(setters, dep.propSetterName); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (isPresent(dep.attributeName)) { | 
					
						
							|  |  |  |         ListWrapper.push(readAttributes, dep.attributeName); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     return new renderApi.DirectiveMetadata({ | 
					
						
							|  |  |  |       id: stringify(directiveBinding.key.token), | 
					
						
							|  |  |  |       type: renderType, | 
					
						
							|  |  |  |       selector: ann.selector, | 
					
						
							|  |  |  |       compileChildren: compileChildren, | 
					
						
							|  |  |  |       events: isPresent(ann.events) ? MapWrapper.createFromStringMap(ann.events) : null, | 
					
						
							|  |  |  |       bind: isPresent(ann.bind) ? MapWrapper.createFromStringMap(ann.bind) : null, | 
					
						
							|  |  |  |       setters: setters, | 
					
						
							|  |  |  |       readAttributes: readAttributes | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2014-11-11 17:33:47 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-02-12 14:44:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   _flattenDirectives(template: Template):List<Type> { | 
					
						
							|  |  |  |     if (isBlank(template.directives)) return []; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     var directives = []; | 
					
						
							|  |  |  |     this._flattenList(template.directives, directives); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return directives; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   _flattenList(tree:List<any>, out:List<Type>) { | 
					
						
							|  |  |  |     for (var i = 0; i < tree.length; i++) { | 
					
						
							|  |  |  |       var item = tree[i]; | 
					
						
							|  |  |  |       if (ListWrapper.isList(item)) { | 
					
						
							|  |  |  |         this._flattenList(item, out); | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         ListWrapper.push(out, item); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-28 16:29:11 -07:00
										 |  |  | } |