From 3aac2fefd7f93c74abfa5ee58aa0ea8d4840b519 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Wed, 29 Apr 2015 15:07:55 -0700 Subject: [PATCH] refactor(compiler): remove `Viewport` directives, use `Decorator` instead BREAKING_CHANGE: - The special type of `Viewport` directives is removed in favor of a more general `Decorator` directive - `ViewContainerRef` now no more has a default `ProtoViewRef` but requires an explicit one when creating views. Closes #1536 --- modules/angular2/docs/core/01_templates.md | 12 +- modules/angular2/docs/core/02_directives.md | 29 ++- modules/angular2/docs/core/10_view.md | 22 +- .../src/core/annotations_impl/annotations.js | 222 ++++++++---------- .../angular2/src/core/compiler/compiler.js | 4 +- .../core/compiler/dynamic_component_loader.js | 2 +- .../src/core/compiler/element_binder.js | 9 +- .../src/core/compiler/element_injector.js | 5 +- .../src/core/compiler/proto_view_factory.js | 13 +- .../angular2/src/core/compiler/query_list.js | 2 +- modules/angular2/src/core/compiler/view.js | 4 +- .../src/core/compiler/view_container_ref.js | 10 +- .../src/core/compiler/view_manager_utils.js | 4 +- modules/angular2/src/directives/for.js | 16 +- modules/angular2/src/directives/if.js | 11 +- modules/angular2/src/directives/switch.js | 122 ++++++---- modules/angular2/src/render/api.js | 3 +- .../render/dom/compiler/directive_parser.js | 28 +-- modules/angular2/src/router/router_outlet.js | 2 +- .../directive_metadata_reader.dart | 2 - .../test/core/compiler/compiler_spec.js | 20 +- .../directive_metadata_reader_spec.js | 11 +- .../compiler/dynamic_component_loader_spec.js | 4 +- .../core/compiler/element_injector_spec.js | 6 + .../test/core/compiler/integration_spec.js | 15 +- .../core/compiler/view_container_ref_spec.js | 4 +- .../test/core/compiler/view_manager_spec.js | 4 +- .../core/compiler/view_manager_utils_spec.js | 4 +- .../dom/compiler/directive_parser_spec.js | 35 --- .../angular2/test/render/dom/convert_spec.js | 4 +- .../shadow_dom_emulation_integration_spec.js | 4 +- modules/angular2/test/router/outlet_spec.js | 2 +- modules/angular2/test/router/router_spec.js | 2 +- modules/benchmarks/src/tree/tree_benchmark.js | 2 +- .../examples/src/hello_world/index_common.js | 7 +- 35 files changed, 280 insertions(+), 366 deletions(-) diff --git a/modules/angular2/docs/core/01_templates.md b/modules/angular2/docs/core/01_templates.md index 8e6da56829..478185ba05 100644 --- a/modules/angular2/docs/core/01_templates.md +++ b/modules/angular2/docs/core/01_templates.md @@ -5,7 +5,7 @@ projected to DOM as well as which DOM events should invoke which methods on the syntax which is core to Angular and allows for data-binding, event-binding, template-instantiation. The design of the template syntax has these properties: - + * All data-binding expressions are easily identifiable. (i.e. there is never an ambiguity whether the value should be interpreted as string literal or as an expression.) @@ -372,8 +372,8 @@ Where: inserted. The template can be defined implicitly with `template` attribute, which turns the current element into a template, or explicitly with ` ``` -NOTE: Only Viewport directives can be placed on the template element. (Decorators and Components are not allowed.) - ### Template Microsyntax @@ -514,7 +512,7 @@ Where: * `some-element` Any element which can generate DOM events (or has an angular directive which generates the event). * `some-event` (escaped with `()` or `on-`) is the name of the event `some-event`. In this case the dash-case is converted into camel-case `someEvent`. -* `statement` is a valid statement (as defined in section below). +* `statement` is a valid statement (as defined in section below). If the execution of the statement returns `false`, then `preventDefault`is applied on the DOM event. By default, angular only listens to the element on the event, and ignores events which bubble. To listen to bubbled diff --git a/modules/angular2/docs/core/02_directives.md b/modules/angular2/docs/core/02_directives.md index 4c6504780a..6a5da8afe3 100644 --- a/modules/angular2/docs/core/02_directives.md +++ b/modules/angular2/docs/core/02_directives.md @@ -10,7 +10,6 @@ There are three different kinds of directives (described in more detail in later 1. *Decorators*: can be placed on any DOM element and can be combined with other directives. 2. *Components*: Components have an encapsulated view and can configure injectors. -3. *Viewport*: is responsible for adding or removing child views in a parent view. (i.e. for, if) @@ -163,21 +162,19 @@ Example of usage: -## Viewport +## Directives that use a ViewContainer -Viewport is a directive which can control instantiation of child views which are then inserted into the DOM. (Examples are `if` and `for`.) +Directives that use a ViewContainer can control instantiation of child views which are then inserted into the DOM. (Examples are `if` and `for`.) -* Viewports can only be placed on `