From e6c8bde808ddaae7dd42fb2c2c4aae09ad8223c8 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Thu, 12 Feb 2015 14:44:59 +0100 Subject: [PATCH] feat(Compiler): Multiple template per component fixes #596 - TemplateConfig becomes Template - introduce a TemplateResolver to pick the cmp template, - @Component and @Template are disociated --- modules/angular2/core.js | 2 +- .../src/core/annotations/annotations.js | 5 - .../{template_config.js => template.js} | 16 +- modules/angular2/src/core/application.js | 4 +- .../angular2/src/core/compiler/compiler.js | 90 ++++-- .../src/core/compiler/directive_metadata.js | 8 +- .../compiler/directive_metadata_reader.js | 33 +-- .../src/core/compiler/template_loader.js | 24 +- .../src/core/compiler/template_resolver.js | 38 +++ modules/angular2/src/forms/directives.js | 8 +- .../angular2/test/core/application_spec.js | 38 +-- .../test/core/compiler/compiler_spec.js | 263 +++++++++--------- .../directive_metadata_reader_spec.js | 73 ++--- .../test/core/compiler/integration_spec.js | 144 +++++++--- .../pipeline/directive_parser_spec.js | 15 +- .../pipeline/element_binder_builder_spec.js | 4 +- .../pipeline/shadow_dom_transformer_spec.js | 2 +- .../shadow_dom_emulation_integration_spec.js | 139 ++++----- .../core/compiler/template_loader_spec.js | 57 ++-- .../angular2/test/core/compiler/view_spec.js | 6 +- .../angular2/test/directives/foreach_spec.js | 55 +++- modules/angular2/test/directives/if_spec.js | 55 +++- .../test/directives/non_bindable_spec.js | 54 +++- .../angular2/test/directives/switch_spec.js | 54 +++- .../angular2/test/forms/integration_spec.js | 65 +++-- .../src/compiler/compiler_benchmark.js | 54 ++-- .../src/naive_infinite_scroll/app.js | 39 ++- .../src/naive_infinite_scroll/cells.js | 76 ++--- .../src/naive_infinite_scroll/index.js | 17 +- .../src/naive_infinite_scroll/scroll_area.js | 34 +-- .../src/naive_infinite_scroll/scroll_item.js | 94 +++---- modules/benchmarks/src/tree/tree_benchmark.js | 42 +-- modules/examples/src/gestures/index.js | 10 +- .../examples/src/hello_world/index_common.js | 28 +- .../examples/src/hello_world/index_static.js | 31 ++- 35 files changed, 953 insertions(+), 724 deletions(-) rename modules/angular2/src/core/annotations/{template_config.js => template.js} (68%) create mode 100644 modules/angular2/src/core/compiler/template_resolver.js diff --git a/modules/angular2/core.js b/modules/angular2/core.js index e1fa618601..19d6774686 100644 --- a/modules/angular2/core.js +++ b/modules/angular2/core.js @@ -1,7 +1,7 @@ export * from './src/core/annotations/annotations'; export * from './src/core/annotations/visibility'; export * from './src/core/compiler/interfaces'; -export * from './src/core/annotations/template_config'; +export * from './src/core/annotations/template'; export * from './src/core/application'; export * from './src/core/compiler/compiler'; diff --git a/modules/angular2/src/core/annotations/annotations.js b/modules/angular2/src/core/annotations/annotations.js index b02d6d6b85..b0a4e0882a 100644 --- a/modules/angular2/src/core/annotations/annotations.js +++ b/modules/angular2/src/core/annotations/annotations.js @@ -1,6 +1,5 @@ import {ABSTRACT, CONST, normalizeBlank, isPresent} from 'angular2/src/facade/lang'; import {ListWrapper, List} from 'angular2/src/facade/collection'; -import {TemplateConfig} from './template_config'; @ABSTRACT() export class Directive { @@ -38,7 +37,6 @@ export class Directive { export class Component extends Directive { //TODO: vsavkin: uncomment it once the issue with defining fields in a sublass works - template:any; //TemplateConfig; lightDomServices:any; //List; shadowDomServices:any; //List; componentServices:any; //List; @@ -48,7 +46,6 @@ export class Component extends Directive { constructor({ selector, bind, - template, lightDomServices, shadowDomServices, componentServices, @@ -57,7 +54,6 @@ export class Component extends Directive { }:{ selector:String, bind:Object, - template:TemplateConfig, lightDomServices:List, shadowDomServices:List, componentServices:List, @@ -73,7 +69,6 @@ export class Component extends Directive { lifecycle: lifecycle }); - this.template = template; this.lightDomServices = lightDomServices; this.shadowDomServices = shadowDomServices; this.componentServices = componentServices; diff --git a/modules/angular2/src/core/annotations/template_config.js b/modules/angular2/src/core/annotations/template.js similarity index 68% rename from modules/angular2/src/core/annotations/template_config.js rename to modules/angular2/src/core/annotations/template.js index edd6e95878..0e1b23eb86 100644 --- a/modules/angular2/src/core/annotations/template_config.js +++ b/modules/angular2/src/core/annotations/template.js @@ -1,25 +1,31 @@ import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang'; import {List} from 'angular2/src/facade/collection'; -export class TemplateConfig { +export class Template { url:any; //string; inline:any; //string; directives:any; //List; formatters:any; //List; - source:any;//List; + source:any;//List