From bf7933714a884e10124ce43aa27d63791fc37e6a Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Thu, 9 Apr 2015 21:20:11 +0200 Subject: [PATCH] chore(rename): rename View and Template concepts for #1244 --- modules/angular2/core.js | 2 +- modules/angular2/docs/core/02_directives.md | 22 +-- modules/angular2/docs/core/10_view.md | 10 +- .../src/core/annotations/annotations.js | 143 +++++++-------- .../core/annotations/{template.js => view.js} | 28 +-- .../src/core/annotations/visibility.js | 40 ++--- modules/angular2/src/core/application.js | 14 +- .../angular2/src/core/compiler/compiler.js | 40 ++--- .../core/compiler/dynamic_component_loader.js | 4 +- .../src/core/compiler/element_binder.js | 6 +- .../src/core/compiler/element_injector.js | 18 +- .../angular2/src/core/compiler/ng_element.js | 4 +- .../src/core/compiler/proto_view_factory.js | 6 +- .../src/core/compiler/template_resolver.js | 16 +- modules/angular2/src/core/compiler/view.js | 39 ++-- .../src/core/compiler/view_container.js | 20 +-- .../src/core/compiler/view_factory.js | 12 +- modules/angular2/src/directives/class.js | 2 +- modules/angular2/src/directives/for.js | 6 +- modules/angular2/src/directives/if.js | 2 +- modules/angular2/src/directives/switch.js | 4 +- modules/angular2/src/forms/directives.js | 10 +- .../src/mock/template_resolver_mock.js | 78 ++++---- modules/angular2/src/render/api.js | 42 ++--- .../dom/compiler/compile_step_factory.js | 8 +- .../src/render/dom/compiler/compiler.js | 8 +- .../render/dom/compiler/directive_parser.js | 8 +- .../render/dom/compiler/template_loader.js | 10 +- .../src/render/dom/direct_dom_renderer.js | 18 +- .../emulated_unscoped_shadow_dom_strategy.js | 6 +- .../src/render/dom/shadow_dom/light_dom.js | 8 +- .../shadow_dom/native_shadow_dom_strategy.js | 2 +- .../dom/shadow_dom/shadow_dom_compile_step.js | 6 +- .../dom/shadow_dom/shadow_dom_strategy.js | 4 +- .../src/render/dom/view/element_binder.js | 2 +- .../src/render/dom/view/proto_view.js | 4 +- .../src/render/dom/view/proto_view_builder.js | 14 +- modules/angular2/src/render/dom/view/view.js | 12 +- .../src/render/dom/view/view_container.js | 6 +- .../src/render/dom/view/view_factory.js | 14 +- modules/angular2/src/test_lib/test_bed.js | 30 ++-- .../src/transform/bind_generator/visitor.dart | 6 +- .../directive_processor/rewriter.dart | 2 +- .../directive_processor/transformer.dart | 2 +- .../src/transform/in_progress/codegen.dart | 6 +- .../src/transform/in_progress/resolvers.dart | 4 +- .../template_compiler/generator.dart | 10 +- .../angular2/test/core/application_spec.js | 14 +- .../test/core/compiler/compiler_spec.js | 82 ++++----- .../core/compiler/element_injector_spec.js | 16 +- .../test/core/compiler/integration_spec.js | 166 +++++++++--------- .../core/compiler/query_integration_spec.js | 10 +- .../angular2/test/directives/class_spec.js | 4 +- modules/angular2/test/directives/for_spec.js | 4 +- modules/angular2/test/directives/if_spec.js | 4 +- .../test/directives/non_bindable_spec.js | 4 +- .../angular2/test/directives/switch_spec.js | 4 +- .../angular2/test/forms/integration_spec.js | 6 +- .../test/mock/template_resolver_mock_spec.js | 34 ++-- .../dom/compiler/compiler_common_tests.js | 26 +-- .../dom/compiler/directive_parser_spec.js | 6 +- .../dom/compiler/template_loader_spec.js | 16 +- .../direct_dom_renderer_integration_spec.js | 30 ++-- .../test/render/dom/integration_testbed.js | 18 +- ...mulated_scoped_shadow_dom_strategy_spec.js | 4 +- ...lated_unscoped_shadow_dom_strategy_spec.js | 4 +- .../render/dom/shadow_dom/light_dom_spec.js | 4 +- .../native_shadow_dom_strategy_spec.js | 4 +- .../shadow_dom_emulation_integration_spec.js | 62 +++---- .../transform/bind_generator/all_tests.dart | 2 +- .../basic_bind_files/bar.ng_deps.dart | 2 +- .../expected/bar.ng_deps.dart | 2 +- .../expected/soup.ng_deps.dart | 4 +- .../soup.ng_deps.dart | 4 +- .../simple_files/bar.ng_deps.dart | 2 +- .../simple_files/expected/bar.ng_deps.dart | 2 +- .../test/transform/integration/all_tests.dart | 4 +- .../two_annotations_files/bar.dart | 4 +- .../expected/bar.ng_deps.dart | 6 +- .../expected/hello.ng_deps.dart | 4 +- .../hello.ng_deps.dart | 4 +- .../expected/hello.ng_deps.dart | 4 +- .../inline_method_files/hello.ng_deps.dart | 4 +- .../expected/hello.ng_deps.dart | 4 +- .../url_expression_files/hello.ng_deps.dart | 4 +- .../expected/hello.ng_deps.dart | 4 +- .../url_method_files/hello.ng_deps.dart | 4 +- modules/angular2/{template.js => view.js} | 0 .../src/compiler/compiler_benchmark.js | 30 ++-- .../src/largetable/largetable_benchmark.js | 20 +-- .../src/naive_infinite_scroll/app.js | 6 +- .../src/naive_infinite_scroll/cells.js | 38 ++-- .../src/naive_infinite_scroll/index.js | 6 +- .../src/naive_infinite_scroll/scroll_area.js | 6 +- .../src/naive_infinite_scroll/scroll_item.js | 8 +- modules/benchmarks/src/tree/tree_benchmark.js | 14 +- .../src/tree/polymer/binary_tree.html | 2 +- modules/examples/src/forms/index.es6 | 22 +-- modules/examples/src/gestures/index.js | 4 +- .../examples/src/hello_world/index_common.js | 8 +- .../examples/src/hello_world/index_static.js | 8 +- modules/examples/src/key_events/index.js | 8 +- modules/examples/src/todo/index.js | 8 +- 103 files changed, 767 insertions(+), 765 deletions(-) rename modules/angular2/src/core/annotations/{template.js => view.js} (77%) rename modules/angular2/{template.js => view.js} (100%) diff --git a/modules/angular2/core.js b/modules/angular2/core.js index ca1c4573bb..dda0bbf525 100644 --- a/modules/angular2/core.js +++ b/modules/angular2/core.js @@ -1,6 +1,6 @@ export * from './src/core/annotations/visibility'; export * from './src/core/compiler/interfaces'; -export * from './src/core/annotations/template'; +export * from './src/core/annotations/view'; export * from './src/core/application'; export * from './src/core/application_tokens'; export * from './src/core/annotations/di'; diff --git a/modules/angular2/docs/core/02_directives.md b/modules/angular2/docs/core/02_directives.md index 113ba6fb89..c528b4e385 100644 --- a/modules/angular2/docs/core/02_directives.md +++ b/modules/angular2/docs/core/02_directives.md @@ -67,10 +67,10 @@ Here is a trivial example of a tooltip decorator. The directive will log a toolt ``` @Decorator({ selector: '[tooltip]', // CSS Selector which triggers the decorator - bind: { // List which properties need to be bound + properties: { // List which properties need to be bound text: 'tooltip' // - DOM element tooltip property should be }, // mapped to the directive text property. - events: { // List which events need to be mapped. + hostListeners: { // List which events need to be mapped. mouseover: 'show' // - Invoke the show() method every time } // the mouseover event is fired. }) @@ -112,13 +112,13 @@ Example of a component: ``` @Component({ | Component annotation selector: 'pane', | CSS selector on element - bind: { | List which property need to be bound + properties: { | List which property need to be bound 'title': 'title', | - title mapped to component title 'open': 'open' | - open attribute mapped to component's open property }, | }) | -@Template({ | Template annotation - url: 'pane.html' | - URL of template HTML +@View({ | View annotation + templateUrl: 'pane.html' | - URL of template HTML }) | class Pane { | Component controller class title:string; | - title property @@ -179,7 +179,7 @@ Viewport is a directive which can control instantiation of child views which are ``` @Viewport({ selector: '[if]', - bind: { + properties: { 'condition': 'if' } }) @@ -220,7 +220,7 @@ To better understand the kinds of injections which are supported in Angular we h ### Injecting Services -Service injection is the most straight forward kind of injection which Angular supports. It involves a component configuring the `services` and then letting the directive ask for the configured service. +Service injection is the most straight forward kind of injection which Angular supports. It involves a component configuring the `injectables` and then letting the directive ask for the configured service. This example illustrates how to inject `MyService` into `House` directive. @@ -231,10 +231,10 @@ class MyService {} | Assume a service which needs to be inject | @Component({ | Assume a top level application component which selector: 'my-app', | configures the services to be injected. - services: [MyService] | + injectables: [MyService] | }) | -@Template({ | Assume we have a template that needs to be - url: 'my_app.html', | configured with directives to be injected. +@View({ | Assume we have a template that needs to be + templateUrl: 'my_app.html', | configured with directives to be injected. directives: [House] | }) | class MyApp {} | @@ -279,7 +279,7 @@ Here is an example of the kinds of injections which can be achieved: @Component({ | selector: 'my-app', | template: new TemplateConfig({ | - url: 'my_app.html', | + templateUrl: 'my_app.html', | directives: [Form, FieldSet, | Field, Primary] | }) | diff --git a/modules/angular2/docs/core/10_view.md b/modules/angular2/docs/core/10_view.md index efa264f09a..6e4efd112c 100644 --- a/modules/angular2/docs/core/10_view.md +++ b/modules/angular2/docs/core/10_view.md @@ -12,12 +12,12 @@ Views form a tree structure which mimics the DOM tree. nested in a tree like structure. The View tree is a simplified version of the DOM tree. A View can have a single DOM Element or large DOM structures. The key is that the DOM tree in the View can not undergo structural changes (only property changes). -* Views represent a running instance of a DOM Template. This implies that while elements in a View +* Views represent a running instance of a DOM View. This implies that while elements in a View can change properties, they can not change structurally. (Structural changes such as, adding or removing elements requires adding or removing child Views into ViewContainers). * View can have zero or more ViewPorts. A ViewPort is a marker in the DOM which allows the insertion of child Views. -* Views are created from a ProtoView. A ProtoView is a compiled DOM Template which is efficient at +* Views are created from a ProtoView. A ProtoView is a compiled DOM View which is efficient at creating Views. * View contains a context object. The context represents the object instance against which all expressions are evaluated. @@ -40,7 +40,7 @@ class Greeter { } ``` -And assume following HTML Template: +And assume following HTML View: ```
@@ -90,7 +90,7 @@ Note: An important part of an application is to be able to change the DOM structure to render data for the user. In Angular this is done by inserting child views into the ViewPort. -Let's start with a Template such as: +Let's start with a View such as: ```
    @@ -194,7 +194,7 @@ class Greeter { } ``` -And assume the following HTML Template: +And assume the following HTML View: ```
    | viewA(greeter) diff --git a/modules/angular2/src/core/annotations/annotations.js b/modules/angular2/src/core/annotations/annotations.js index d8c2d99429..d48fe35bc6 100644 --- a/modules/angular2/src/core/annotations/annotations.js +++ b/modules/angular2/src/core/annotations/annotations.js @@ -86,7 +86,7 @@ import {Injectable} from 'angular2/di'; * * @Decorator({ * selector: '[dependency]', - * bind: { + * properties: { * 'id':'dependency' * } * }) @@ -272,7 +272,8 @@ export class Directive extends Injectable { /** * Enumerates the set of properties that accept data binding for a directive. * - * The `bind` property defines a set of `directiveProperty` to `bindingProperty` key-value pairs: + * The `properties` property defines a set of `directiveProperty` to `bindingProperty` + * key-value pairs: * * - `directiveProperty` specifies the component property where the value is written. * - `bindingProperty` specifies the DOM property where the value is read from. @@ -285,7 +286,7 @@ export class Directive extends Injectable { * * ``` * @Directive({ - * bind: { + * properties: { * 'directiveProperty1': 'bindingProperty1', * 'directiveProperty2': 'bindingProperty2 | pipe1 | ...', * ... @@ -302,7 +303,7 @@ export class Directive extends Injectable { * ``` * @Decorator({ * selector: '[tooltip]', - * bind: { + * properties: { * 'text': 'tooltip' * } * }) @@ -321,8 +322,8 @@ export class Directive extends Injectable { *
    ...
    * ``` * - * Whenever the `someExpression` expression changes, the `bind` declaration instructs Angular to update the - * `Tooltip`'s `text` property. + * Whenever the `someExpression` expression changes, the `properties` declaration instructs + * Angular to update the `Tooltip`'s `text` property. * * * @@ -336,7 +337,7 @@ export class Directive extends Injectable { * ``` * @Decorator({ * selector: '[class-set]', - * bind: { + * properties: { * 'classChanges': 'classSet | keyValDiff' * } * }) @@ -356,12 +357,12 @@ export class Directive extends Injectable { * In this case, the two pipes compose as if they were inlined: `someExpression | somePipe | keyValDiff`. * */ - bind:any; // StringMap + properties:any; // StringMap /** - * Specifies which DOM events a directive listens to. + * Specifies which DOM hostListeners a directive listens to. * - * The `events` property defines a set of `event` to `method` key-value pairs: + * The `hostListeners` property defines a set of `event` to `method` key-value pairs: * * - `event1`: the DOM event that the directive listens to. * - `statement`: the statement to execute when the event occurs. @@ -377,7 +378,7 @@ export class Directive extends Injectable { * * ``` * @Directive({ - * events: { + * hostListeners: { * 'event1': 'onMethod1(arguments)', * ... * } @@ -386,13 +387,13 @@ export class Directive extends Injectable { * * ## Basic Event Binding: * - * Suppose you want to write a directive that triggers on `change` events in the DOM. You would define the event + * Suppose you want to write a directive that triggers on `change` hostListeners in the DOM. You would define the event * binding as follows: * * ``` * @Decorator({ * selector: 'input', - * events: { + * hostListeners: { * 'change': 'onChange($event)' * } * }) @@ -405,10 +406,10 @@ export class Directive extends Injectable { * Here the `onChange` method of `InputDecorator` is invoked whenever the DOM element fires the 'change' event. * */ - events:any; // StringMap + hostListeners:any; // StringMap /** - * Specifies a set of lifecycle events in which the directive participates. + * Specifies a set of lifecycle hostListeners in which the directive participates. * * See: [onChange], [onDestroy], [onAllChangesDone] for details. */ @@ -417,20 +418,20 @@ export class Directive extends Injectable { @CONST() constructor({ selector, - bind, - events, + properties, + hostListeners, lifecycle }:{ selector:string, - bind:any, - events: any, + properties:any, + hostListeners: any, lifecycle:List }={}) { super(); this.selector = selector; - this.bind = bind; - this.events = events; + this.properties = properties; + this.hostListeners = hostListeners; this.lifecycle = lifecycle; } @@ -447,17 +448,17 @@ export class Directive extends Injectable { /** * Declare reusable UI building blocks for an application. * - * Each Angular component requires a single `@Component` and at least one `@Template` annotation. The `@Component` - * annotation specifies when a component is instantiated, and which properties and events it binds to. + * Each Angular component requires a single `@Component` and at least one `@View` annotation. The `@Component` + * annotation specifies when a component is instantiated, and which properties and hostListeners it binds to. * * When a component is instantiated, Angular * - creates a shadow DOM for the component. * - loads the selected template into the shadow DOM. - * - creates a child [Injector] which is configured with the [Component.services]. + * - creates a child [Injector] which is configured with the [Component.injectables]. * * All template expressions and statements are then evaluated against the component instance. * - * For details on the `@Template` annotation, see [Template]. + * For details on the `@View` annotation, see [View]. * * ## Example * @@ -465,8 +466,8 @@ export class Directive extends Injectable { * @Component({ * selector: 'greet' * }) - * @Template({ - * inline: 'Hello {{name}}!' + * @View({ + * template: 'Hello {{name}}!' * }) * class Greet { * name: string; @@ -494,16 +495,16 @@ export class Component extends Directive { /** * Defines the set of injectable objects that are visible to a Component and its children. * - * The [services] defined in the Component annotation allow you to configure a set of bindings for the component's + * The [injectables] defined in the Component annotation allow you to configure a set of bindings for the component's * injector. * * When a component is instantiated, Angular creates a new child Injector, which is configured with the bindings in - * the Component [services] annotation. The injectable objects then become available for injection to the component + * the Component [injectables] annotation. The injectable objects then become available for injection to the component * itself and any of the directives in the component's template, i.e. they are not available to the directives which * are children in the component's light DOM. * * - * The syntax for configuring the [services] injectable is identical to [Injector] injectable configuration. See + * The syntax for configuring the [injectables] injectable is identical to [Injector] injectable configuration. See * [Injector] for additional detail. * * @@ -520,12 +521,12 @@ export class Component extends Directive { * * @Component({ * selector: 'greet', - * services: [ + * injectables: [ * Greeter * ] * }) - * @Template({ - * inline: `{{greeter.greet('world')}}!`, + * @View({ + * template: `{{greeter.greet('world')}}!`, * directives: Child * }) * class HelloWorld { @@ -537,34 +538,34 @@ export class Component extends Directive { * } * ``` */ - services:List; + injectables:List; @CONST() constructor({ selector, - bind, - events, - services, + properties, + hostListeners, + injectables, lifecycle, changeDetection }:{ selector:string, - bind:Object, - events:Object, - services:List, + properties:Object, + hostListeners:Object, + injectables:List, lifecycle:List, changeDetection:string }={}) { super({ selector: selector, - bind: bind, - events: events, + properties: properties, + hostListeners: hostListeners, lifecycle: lifecycle }); this.changeDetection = changeDetection; - this.services = services; + this.injectables = injectables; } } @@ -600,8 +601,8 @@ export class Component extends Directive { * @Component({ * selector: 'hello-cmp' * }) - * @Template({ - * inline: "{{greeting}}" + * @View({ + * template: "{{greeting}}" * }) * class HelloCmp { * greeting:string; @@ -617,33 +618,33 @@ export class Component extends Directive { */ export class DynamicComponent extends Directive { /** - * Same as [Component.services]. + * Same as [Component.injectables]. */ // TODO(vsankin): Please extract into AbstractComponent - services:any; //List; + injectables:any; //List; @CONST() constructor({ selector, - bind, - events, - services, + properties, + hostListeners, + injectables, lifecycle }:{ selector:string, - bind:Object, - events:Object, - services:List, + properties:Object, + hostListeners:Object, + injectables:List, lifecycle:List }={}) { super({ selector: selector, - bind: bind, - events: events, + properties: properties, + hostListeners: hostListeners, lifecycle: lifecycle }); - this.services = services; + this.injectables = injectables; } } @@ -670,10 +671,10 @@ export class DynamicComponent extends Directive { * ``` * @Decorator({ * selector: '[tooltip]', - * bind: { + * properties: { * 'text': 'tooltip' * }, - * events: { + * hostListeners: { * 'onmouseenter': 'onMouseEnter()', * 'onmouseleave': 'onMouseLeave()' * } @@ -718,22 +719,22 @@ export class Decorator extends Directive { @CONST() constructor({ selector, - bind, - events, + properties, + hostListeners, lifecycle, compileChildren = true, }:{ selector:string, - bind:any, - events:any, + properties:any, + hostListeners:any, lifecycle:List, compileChildren:boolean }={}) { super({ selector: selector, - bind: bind, - events: events, + properties: properties, + hostListeners: hostListeners, lifecycle: lifecycle }); this.compileChildren = compileChildren; @@ -784,7 +785,7 @@ export class Decorator extends Directive { * ``` * @Viewport({ * selector: '[unless]', - * bind: { + * properties: { * 'condition': 'unless' * } * }) @@ -837,19 +838,19 @@ export class Viewport extends Directive { @CONST() constructor({ selector, - bind, - events, + properties, + hostListeners, lifecycle }:{ selector:string, - bind:any, + properties:any, lifecycle:List }={}) { super({ selector: selector, - bind: bind, - events: events, + properties: properties, + hostListeners: hostListeners, lifecycle: lifecycle }); } @@ -891,7 +892,7 @@ export const onDestroy = "onDestroy"; * ``` * @Decorator({ * selector: '[class-set]', - * bind: { + * properties: { * 'propA': 'propA' * 'propB': 'propB' * }, diff --git a/modules/angular2/src/core/annotations/template.js b/modules/angular2/src/core/annotations/view.js similarity index 77% rename from modules/angular2/src/core/annotations/template.js rename to modules/angular2/src/core/annotations/view.js index 43f285fdd4..4da9c3c575 100644 --- a/modules/angular2/src/core/annotations/template.js +++ b/modules/angular2/src/core/annotations/view.js @@ -3,7 +3,7 @@ import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang'; /** * Declare the available HTML templates for an application. * - * Each angular component requires a single `@Component` and at least one `@Template` annotation. The @Template + * Each angular component requires a single `@Component` and at least one `@View` annotation. The @View * annotation specifies the HTML template to use, and lists the directives that are active within the template. * * When a component is instantiated, the template is loaded into the component's shadow root, and the @@ -17,8 +17,8 @@ import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang'; * @Component({ * selector: 'greet' * }) - * @Template({ - * inline: 'Hello {{name}}!' + * @View({ + * template: 'Hello {{name}}!' * }) * class Greet { * name: string; @@ -31,35 +31,35 @@ import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang'; * * @publicModule angular2/annotations */ -export class Template { - url:any; //string; - inline:any; //string; +export class View { + templateUrl:any; //string; + template:any; //string; directives:any; //List; formatters:any; //List; - source:any;//List