From 0b3e4fa090eca6382d601253854f7aa4ba47a16a Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Mon, 5 Oct 2015 10:10:07 -0700 Subject: [PATCH] refactor(core): move `ViewEncapsulation` and `ViewType` to the right places Closes #4526 --- .../src/core/compiler/command_compiler.ts | 2 +- .../src/core/compiler/directive_metadata.ts | 2 +- .../src/core/compiler/style_compiler.ts | 2 +- .../src/core/compiler/template_normalizer.ts | 3 +- .../src/core/linker/proto_view_factory.ts | 4 +- modules/angular2/src/core/linker/view.ts | 16 ++++++- .../angular2/src/core/linker/view_manager.ts | 11 +++-- .../src/core/linker/view_manager_utils.ts | 9 ++-- modules/angular2/src/core/metadata.dart | 2 +- modules/angular2/src/core/metadata/view.ts | 33 +++++++++++++- modules/angular2/src/core/render/api.ts | 45 ------------------- .../src/web_workers/shared/serializer.ts | 19 +------- .../core/compiler/command_compiler_spec.ts | 2 +- .../core/compiler/directive_metadata_spec.ts | 2 +- .../test/core/compiler/style_compiler_spec.ts | 2 +- .../core/compiler/template_compiler_spec.ts | 2 +- .../core/compiler/template_normalizer_spec.ts | 2 +- .../test/core/linker/view_manager_spec.ts | 3 +- .../core/linker/view_manager_utils_spec.ts | 9 +++- .../common/directive_metadata_reader.dart | 2 +- 20 files changed, 77 insertions(+), 95 deletions(-) diff --git a/modules/angular2/src/core/compiler/command_compiler.ts b/modules/angular2/src/core/compiler/command_compiler.ts index e9f29862f0..976eab4358 100644 --- a/modules/angular2/src/core/compiler/command_compiler.ts +++ b/modules/angular2/src/core/compiler/command_compiler.ts @@ -30,7 +30,7 @@ import { import {CompileTypeMetadata, CompileDirectiveMetadata} from './directive_metadata'; import {SourceExpressions, SourceExpression, moduleRef} from './source_module'; -import {ViewEncapsulation} from 'angular2/src/core/render/api'; +import {ViewEncapsulation} from 'angular2/src/core/metadata/view'; import { shimHostAttribute, shimContentAttribute, diff --git a/modules/angular2/src/core/compiler/directive_metadata.ts b/modules/angular2/src/core/compiler/directive_metadata.ts index ec344771b5..a0e07cce26 100644 --- a/modules/angular2/src/core/compiler/directive_metadata.ts +++ b/modules/angular2/src/core/compiler/directive_metadata.ts @@ -12,7 +12,7 @@ import { ChangeDetectionStrategy, CHANGE_DECTION_STRATEGY_VALUES } from 'angular2/src/core/change_detection/change_detection'; -import {ViewEncapsulation, VIEW_ENCAPSULATION_VALUES} from 'angular2/src/core/render/api'; +import {ViewEncapsulation, VIEW_ENCAPSULATION_VALUES} from 'angular2/src/core/metadata/view'; import {CssSelector} from 'angular2/src/core/compiler/selector'; import {splitAtColon} from './util'; import {LifecycleHooks, LIFECYCLE_HOOKS_VALUES} from 'angular2/src/core/linker/interfaces'; diff --git a/modules/angular2/src/core/compiler/style_compiler.ts b/modules/angular2/src/core/compiler/style_compiler.ts index e55f32f15b..139ad9bef2 100644 --- a/modules/angular2/src/core/compiler/style_compiler.ts +++ b/modules/angular2/src/core/compiler/style_compiler.ts @@ -1,6 +1,6 @@ import {CompileTypeMetadata, CompileTemplateMetadata} from './directive_metadata'; import {SourceModule, SourceExpression, moduleRef} from './source_module'; -import {ViewEncapsulation} from 'angular2/src/core/render/api'; +import {ViewEncapsulation} from 'angular2/src/core/metadata/view'; import {XHR} from 'angular2/src/core/compiler/xhr'; import {StringWrapper, isBlank} from 'angular2/src/core/facade/lang'; import {PromiseWrapper, Promise} from 'angular2/src/core/facade/async'; diff --git a/modules/angular2/src/core/compiler/template_normalizer.ts b/modules/angular2/src/core/compiler/template_normalizer.ts index 6872d8f22a..a1114cae85 100644 --- a/modules/angular2/src/core/compiler/template_normalizer.ts +++ b/modules/angular2/src/core/compiler/template_normalizer.ts @@ -11,7 +11,8 @@ import {XHR} from 'angular2/src/core/compiler/xhr'; import {UrlResolver} from 'angular2/src/core/compiler/url_resolver'; import {resolveStyleUrls} from './style_url_resolver'; import {Injectable} from 'angular2/src/core/di'; -import {ViewEncapsulation} from 'angular2/src/core/render/api'; +import {ViewEncapsulation} from 'angular2/src/core/metadata/view'; + import { HtmlAstVisitor, diff --git a/modules/angular2/src/core/linker/proto_view_factory.ts b/modules/angular2/src/core/linker/proto_view_factory.ts index 0caa431199..16f3b69dea 100644 --- a/modules/angular2/src/core/linker/proto_view_factory.ts +++ b/modules/angular2/src/core/linker/proto_view_factory.ts @@ -1,14 +1,14 @@ import {ListWrapper} from 'angular2/src/core/facade/collection'; import {isPresent, isBlank, Type, isArray, isNumber} from 'angular2/src/core/facade/lang'; -import {ViewType, RenderProtoViewRef} from 'angular2/src/core/render/api'; +import {RenderProtoViewRef} from 'angular2/src/core/render/api'; import {Injectable, Binding, resolveForwardRef, Inject} from 'angular2/src/core/di'; import {PipeBinding} from '../pipes/pipe_binding'; import {ProtoPipes} from '../pipes/pipes'; -import {AppProtoView, AppProtoViewMergeInfo} from './view'; +import {AppProtoView, AppProtoViewMergeInfo, ViewType} from './view'; import {ElementBinder} from './element_binder'; import {ProtoElementInjector, DirectiveBinding} from './element_injector'; import {DirectiveResolver} from './directive_resolver'; diff --git a/modules/angular2/src/core/linker/view.ts b/modules/angular2/src/core/linker/view.ts index d61018198e..b2eec85a63 100644 --- a/modules/angular2/src/core/linker/view.ts +++ b/modules/angular2/src/core/linker/view.ts @@ -38,6 +38,18 @@ export {DebugContext} from 'angular2/src/core/change_detection/interfaces'; const REFLECT_PREFIX: string = 'ng-reflect-'; +export enum ViewType { + // A view that contains the host element with bound component directive. + // Contains a COMPONENT view + HOST, + // The view of the component + // Can contain 0 to n EMBEDDED views + COMPONENT, + // A view that is embedded into another View via a