refactor: rename annotations to metadata

BREAKING CHANGE (maybe)

Well as long as our customers use public API this should not be a
breaking change, but we have changed import structure as well as
internal names, so it could be breaking.

import:
  angular2/annotations => angular2/metadata

Classes:
  *Annotations => *Metadata
  renderer.DirectiveMetadata => renderer.RendererDirectiveMetadata
  renderer.ElementBinder => renderer.RendererElementBinder
  impl.Directive => impl.DirectiveMetadata
  impl.Component => impl.ComponentMetadata
  impl.View => impl.ViewMetadata

Closes #3660
This commit is contained in:
Misko Hevery 2015-08-14 10:03:45 -07:00 committed by Miško Hevery
parent 5e6317fecc
commit ea6673947c
172 changed files with 1287 additions and 1173 deletions

View File

@ -5,7 +5,7 @@ module.exports = new Package('angular-v2-public-docs', [basePackage])
.config(function(readTypeScriptModules) {
readTypeScriptModules.sourceFiles = [
'angular2/annotations.ts',
'angular2/metadata.ts',
'angular2/change_detection.ts',
'angular2/core.ts',
'angular2/di.ts',

View File

@ -7,7 +7,7 @@ export {commonBootstrap as bootstrap} from 'angular2/src/core/application_common
// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs
// to resolve imports very very very slowly. See also a similar notice in
// bootstrap.ts
export * from './annotations';
export * from './metadata';
export * from './change_detection';
export * from './core';
export * from './di';

View File

@ -1,4 +1,4 @@
export * from './annotations';
export * from './metadata';
export * from './change_detection';
export * from './core';
export * from './di';

View File

@ -1,50 +0,0 @@
/**
* @module
* @description
*
* Annotations provide the additional information that Angular requires in order to run your
* application. This module
* contains {@link Component}, {@link Directive}, and {@link View} annotations, as well as
* the {@link Host} annotation that is used by Angular to resolve dependencies.
*
*/
export {
ComponentAnnotation,
DirectiveAnnotation,
PipeAnnotation,
LifecycleEvent
} from './src/core/annotations/annotations';
export {ViewAnnotation, ViewEncapsulation} from 'angular2/src/core/annotations/view';
export {QueryAnnotation, AttributeAnnotation} from 'angular2/src/core/annotations/di';
export {
OnAllChangesDone,
OnChange,
OnDestroy,
OnInit,
OnCheck
} from 'angular2/src/core/compiler/interfaces';
export {Class, ClassDefinition, TypeDecorator} from 'angular2/src/util/decorators';
export {
Attribute,
AttributeFactory,
Component,
ComponentDecorator,
ComponentFactory,
Directive,
DirectiveDecorator,
DirectiveFactory,
View,
ViewDecorator,
ViewFactory,
Query,
QueryFactory,
ViewQuery,
Pipe,
PipeFactory
} from 'angular2/src/core/annotations/decorators';

View File

@ -7,7 +7,7 @@ export {bootstrap} from 'angular2/src/core/application';
// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs
// to resolve imports very very very slowly. See also a similar notice in
// angular2.ts
export * from './annotations';
export * from './metadata';
export * from './change_detection';
export * from './core';
export * from './di';

View File

@ -0,0 +1,4 @@
library angular2.metadata;
export 'package:angular2/src/core/metadata.dart';
export 'package:angular2/src/core/compiler/interfaces.dart';

View File

@ -0,0 +1,48 @@
/**
* @module
* @description
*
* Annotations provide the additional information that Angular requires in order to run your
* application. This module
* contains {@link ComponentMetadata}, {@link DirectiveMetadata}, and {@link ViewMetadata}
* annotations, as well as
* the {@link Host} annotation that is used by Angular to resolve dependencies.
*
*/
export {
ComponentMetadata,
DirectiveMetadata,
PipeMetadata,
LifecycleEvent,
ViewMetadata,
ViewEncapsulation,
QueryMetadata,
AttributeMetadata,
Attribute,
AttributeFactory,
Component,
ComponentDecorator,
ComponentFactory,
Directive,
DirectiveDecorator,
DirectiveFactory,
View,
ViewDecorator,
ViewFactory,
Query,
QueryFactory,
ViewQuery,
Pipe,
PipeFactory
} from './src/core/metadata';
export {
OnAllChangesDone,
OnChange,
OnDestroy,
OnInit,
OnCheck
} from './src/core/compiler/interfaces';
export {Class, ClassDefinition, TypeDecorator} from './src/util/decorators';

View File

@ -5,7 +5,7 @@
*/
export {
DirectiveMetadata,
RenderDirectiveMetadata,
DomRenderer,
RenderEventDispatcher,
Renderer,

View File

@ -6,7 +6,8 @@ import {implementsOnDestroy} from './pipe_lifecycle_reflector';
/**
* Indicates that the result of a {@link Pipe} transformation has changed even though the reference
* Indicates that the result of a {@link PipeMetadata} transformation has changed even though the
* reference
* has not changed.
*
* The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.

View File

@ -1,8 +0,0 @@
/**
* This indirection is needed for TS compilation path.
* See comment in annotations.es6.
*/
library angular2.core.annotations.annotations;
export "../annotations_impl/annotations.dart";

View File

@ -1,11 +0,0 @@
/**
* This indirection is needed to free up Component, etc symbols in the public API
* to be used by the decorator versions of these annotations.
*/
export {
Component as ComponentAnnotation,
Directive as DirectiveAnnotation,
Pipe as PipeAnnotation,
LifecycleEvent
} from '../annotations_impl/annotations';

View File

@ -1,5 +0,0 @@
library angular2.core.decorators;
export '../annotations_impl/annotations.dart';
export '../annotations_impl/view.dart';
export '../annotations_impl/di.dart';

View File

@ -1,3 +0,0 @@
library angular2.core.annotations.di;
export "../annotations_impl/di.dart";

View File

@ -1,5 +0,0 @@
export {
Query as QueryAnnotation,
ViewQuery as ViewQueryAnnotation,
Attribute as AttributeAnnotation,
} from '../annotations_impl/di';

View File

@ -1,3 +0,0 @@
library angular2.core.annotations.view;
export "../annotations_impl/view.dart";

View File

@ -1 +0,0 @@
export {View as ViewAnnotation, ViewEncapsulation} from '../annotations_impl/view';

View File

@ -359,12 +359,12 @@ export class ApplicationRef {
}
/**
* Returns the current {@link Component} type.
* Returns the current {@link ComponentMetadata} type.
*/
get hostComponentType(): Type { return this._hostComponentType; }
/**
* Returns the current {@link Component} instance.
* Returns the current {@link ComponentMetadata} instance.
*/
get hostComponent(): any { return this._hostComponent.instance; }

View File

@ -20,7 +20,7 @@ import {ProtoViewRef} from './view_ref';
import {DirectiveBinding} from './element_injector';
import {ViewResolver} from './view_resolver';
import {PipeResolver} from './pipe_resolver';
import {View} from '../annotations_impl/view';
import {ViewMetadata} from 'angular2/metadata';
import {ComponentUrlMapper} from './component_url_mapper';
import {ProtoViewFactory} from './proto_view_factory';
import {UrlResolver} from 'angular2/src/services/url_resolver';
@ -30,7 +30,14 @@ import {wtfStartTimeRange, wtfEndTimeRange} from '../../profile/profile';
import {PipeBinding} from '../pipes/pipe_binding';
import {DEFAULT_PIPES_TOKEN} from 'angular2/pipes';
import * as renderApi from 'angular2/src/render/api';
import {
RenderDirectiveMetadata,
ViewDefinition,
RenderCompiler,
ViewType,
RenderProtoViewMergeMapping,
RenderProtoViewRef
} from 'angular2/src/render/api';
/**
* Cache that stores the AppProtoView of the template of a component.
@ -97,8 +104,8 @@ export class Compiler {
@Inject(DEFAULT_PIPES_TOKEN) _defaultPipes: Type[],
private _compilerCache: CompilerCache, private _viewResolver: ViewResolver,
private _componentUrlMapper: ComponentUrlMapper, private _urlResolver: UrlResolver,
private _render: renderApi.RenderCompiler,
private _protoViewFactory: ProtoViewFactory, appUrl: AppRootUrl) {
private _render: RenderCompiler, private _protoViewFactory: ProtoViewFactory,
appUrl: AppRootUrl) {
this._defaultPipes = _defaultPipes;
this._appUrl = appUrl.value;
}
@ -215,7 +222,7 @@ export class Compiler {
componentPath: Map<Type, AppProtoView>): Promise<AppProtoView> {
var nestedPVPromises = [];
componentPath = MapWrapper.clone(componentPath);
if (appProtoViews[0].type === renderApi.ViewType.COMPONENT) {
if (appProtoViews[0].type === ViewType.COMPONENT) {
componentPath.set(componentType, appProtoViews[0]);
}
appProtoViews.forEach(appProtoView => {
@ -230,7 +237,7 @@ export class Compiler {
if (appProtoView.isEmbeddedFragment) {
throw new BaseException(
`<ng-content> is used within the recursive path of ${stringify(nestedComponentType)}`);
} else if (appProtoView.type === renderApi.ViewType.COMPONENT) {
} else if (appProtoView.type === ViewType.COMPONENT) {
throw new BaseException(
`Unconditional component cycle in ${stringify(nestedComponentType)}`);
} else {
@ -253,18 +260,17 @@ export class Compiler {
}
private _mergeProtoView(appProtoView: AppProtoView): Promise<any> {
if (appProtoView.type !== renderApi.ViewType.HOST &&
appProtoView.type !== renderApi.ViewType.EMBEDDED) {
if (appProtoView.type !== ViewType.HOST && appProtoView.type !== ViewType.EMBEDDED) {
return null;
}
return this._render.mergeProtoViewsRecursively(this._collectMergeRenderProtoViews(appProtoView))
.then((mergeResult: renderApi.RenderProtoViewMergeMapping) => {
.then((mergeResult: RenderProtoViewMergeMapping) => {
appProtoView.mergeMapping = new AppProtoViewMergeMapping(mergeResult);
});
}
private _collectMergeRenderProtoViews(
appProtoView: AppProtoView): List<renderApi.RenderProtoViewRef | List<any>> {
private _collectMergeRenderProtoViews(appProtoView:
AppProtoView): List<RenderProtoViewRef | List<any>> {
var result = [appProtoView.render];
for (var i = 0; i < appProtoView.elementBinders.length; i++) {
var binder = appProtoView.elementBinders[i];
@ -290,7 +296,7 @@ export class Compiler {
return componentElementBinders;
}
private _buildRenderTemplate(component, view, directives): renderApi.ViewDefinition {
private _buildRenderTemplate(component, view, directives): ViewDefinition {
var componentUrl =
this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component));
var templateAbsUrl = null;
@ -307,7 +313,7 @@ export class Compiler {
styleAbsUrls =
ListWrapper.map(view.styleUrls, url => this._urlResolver.resolve(componentUrl, url));
}
return new renderApi.ViewDefinition({
return new ViewDefinition({
componentId: stringify(component),
templateAbsUrl: templateAbsUrl, template: view.template,
styleAbsUrls: styleAbsUrls,
@ -317,14 +323,14 @@ export class Compiler {
});
}
private _flattenPipes(view: View): any[] {
private _flattenPipes(view: ViewMetadata): any[] {
if (isBlank(view.pipes)) return this._defaultPipes;
var pipes = ListWrapper.clone(this._defaultPipes);
this._flattenList(view.pipes, pipes);
return pipes;
}
private _flattenDirectives(view: View): List<Type> {
private _flattenDirectives(view: ViewMetadata): List<Type> {
if (isBlank(view.directives)) return [];
var directives = [];
this._flattenList(view.directives, directives);
@ -347,7 +353,7 @@ export class Compiler {
}
private static _assertTypeIsComponent(directiveBinding: DirectiveBinding): void {
if (directiveBinding.metadata.type !== renderApi.DirectiveMetadata.COMPONENT_TYPE) {
if (directiveBinding.metadata.type !== RenderDirectiveMetadata.COMPONENT_TYPE) {
throw new BaseException(
`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
}

View File

@ -3,7 +3,7 @@ import {Type, isPresent} from 'angular2/src/facade/lang';
import {Map, MapWrapper} from 'angular2/src/facade/collection';
/**
* Resolve a `Type` from a {@link Component} into a URL.
* Resolve a `Type` from a {@link ComponentMetadata} into a URL.
*
* This interface can be overridden by the application developer to create custom behavior.
*

View File

@ -1,10 +1,10 @@
library angular2.src.core.compiler.directive_lifecycle_reflector;
import 'package:angular2/src/core/annotations_impl/annotations.dart';
import 'package:angular2/src/core/metadata.dart';
import 'package:angular2/src/core/compiler/interfaces.dart';
import 'package:angular2/src/reflection/reflection.dart';
bool hasLifecycleHook(LifecycleEvent e, type, Directive annotation) {
bool hasLifecycleHook(LifecycleEvent e, type, DirectiveMetadata annotation) {
if (annotation.lifecycle != null) {
return annotation.lifecycle.contains(e);
} else {

View File

@ -1,7 +1,7 @@
import {Type, isPresent} from 'angular2/src/facade/lang';
import {LifecycleEvent, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {LifecycleEvent, DirectiveMetadata} from 'angular2/metadata';
export function hasLifecycleHook(e: LifecycleEvent, type, annotation: Directive): boolean {
export function hasLifecycleHook(e: LifecycleEvent, type, annotation: DirectiveMetadata): boolean {
if (isPresent(annotation.lifecycle)) {
return annotation.lifecycle.indexOf(e) !== -1;
} else {

View File

@ -1,10 +1,10 @@
import {resolveForwardRef, Injectable} from 'angular2/di';
import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
import {Directive} from '../annotations_impl/annotations';
import {DirectiveMetadata} from 'angular2/metadata';
import {reflector} from 'angular2/src/reflection/reflection';
/**
* Resolve a `Type` for {@link Directive}.
* Resolve a `Type` for {@link DirectiveMetadata}.
*
* This interface can be overridden by the application developer to create custom behavior.
*
@ -13,14 +13,14 @@ import {reflector} from 'angular2/src/reflection/reflection';
@Injectable()
export class DirectiveResolver {
/**
* Return {@link Directive} for a given `Type`.
* Return {@link DirectiveMetadata} for a given `Type`.
*/
resolve(type: Type): Directive {
resolve(type: Type): DirectiveMetadata {
var annotations = reflector.annotations(resolveForwardRef(type));
if (isPresent(annotations)) {
for (var i = 0; i < annotations.length; i++) {
var annotation = annotations[i];
if (annotation instanceof Directive) {
if (annotation instanceof DirectiveMetadata) {
return annotation;
}
}

View File

@ -31,19 +31,19 @@ import {
BindingWithVisibility
} from 'angular2/src/di/injector';
import {Attribute, Query} from 'angular2/src/core/annotations_impl/di';
import {AttributeMetadata, QueryMetadata} from '../metadata/di';
import * as viewModule from './view';
import * as avmModule from './view_manager';
import {ViewContainerRef} from './view_container_ref';
import {ElementRef} from './element_ref';
import {TemplateRef} from './template_ref';
import {Directive, Component, LifecycleEvent} from 'angular2/src/core/annotations_impl/annotations';
import {DirectiveMetadata, ComponentMetadata, LifecycleEvent} from '../metadata/directives';
import {hasLifecycleHook} from './directive_lifecycle_reflector';
import {ChangeDetector, ChangeDetectorRef} from 'angular2/src/change_detection/change_detection';
import {QueryList} from './query_list';
import {reflector} from 'angular2/src/reflection/reflection';
import {DirectiveMetadata} from 'angular2/src/render/api';
import {RenderDirectiveMetadata} from 'angular2/src/render/api';
import {PipeBinding} from '../pipes/pipe_binding';
var _staticKeys;
@ -160,7 +160,7 @@ export class TreeNode<T extends TreeNode<any>> {
export class DirectiveDependency extends Dependency {
constructor(key: Key, optional: boolean, lowerBoundVisibility: Object,
upperBoundVisibility: Object, properties: List<any>, public attributeName: string,
public queryDecorator: Query) {
public queryDecorator: QueryMetadata) {
super(key, optional, lowerBoundVisibility, upperBoundVisibility, properties);
this._verify();
}
@ -181,12 +181,12 @@ export class DirectiveDependency extends Dependency {
}
static _attributeName(properties): string {
var p = <Attribute>ListWrapper.find(properties, (p) => p instanceof Attribute);
var p = <AttributeMetadata>ListWrapper.find(properties, (p) => p instanceof AttributeMetadata);
return isPresent(p) ? p.attributeName : null;
}
static _query(properties): Query {
return <Query>ListWrapper.find(properties, (p) => p instanceof Query);
static _query(properties): QueryMetadata {
return <QueryMetadata>ListWrapper.find(properties, (p) => p instanceof QueryMetadata);
}
}
@ -194,7 +194,7 @@ export class DirectiveBinding extends ResolvedBinding {
constructor(key: Key, factory: Function, dependencies: List<Dependency>,
public resolvedBindings: List<ResolvedBinding>,
public resolvedViewBindings: List<ResolvedBinding>,
public metadata: DirectiveMetadata) {
public metadata: RenderDirectiveMetadata) {
super(key, factory, dependencies);
}
@ -218,21 +218,21 @@ export class DirectiveBinding extends ResolvedBinding {
get changeDetection() { return this.metadata.changeDetection; }
static createFromBinding(binding: Binding, ann: Directive): DirectiveBinding {
static createFromBinding(binding: Binding, ann: DirectiveMetadata): DirectiveBinding {
if (isBlank(ann)) {
ann = new Directive();
ann = new DirectiveMetadata();
}
var rb = binding.resolve();
var deps = ListWrapper.map(rb.dependencies, DirectiveDependency.createFrom);
var resolvedBindings = isPresent(ann.bindings) ? Injector.resolve(ann.bindings) : [];
var resolvedViewBindings = ann instanceof Component && isPresent(ann.viewBindings) ?
var resolvedViewBindings = ann instanceof ComponentMetadata && isPresent(ann.viewBindings) ?
Injector.resolve(ann.viewBindings) :
[];
var metadata = DirectiveMetadata.create({
var metadata = RenderDirectiveMetadata.create({
id: stringify(rb.key.token),
type: ann instanceof Component ? DirectiveMetadata.COMPONENT_TYPE :
DirectiveMetadata.DIRECTIVE_TYPE,
type: ann instanceof ComponentMetadata ? RenderDirectiveMetadata.COMPONENT_TYPE :
RenderDirectiveMetadata.DIRECTIVE_TYPE,
selector: ann.selector,
compileChildren: ann.compileChildren,
events: ann.events,
@ -246,7 +246,7 @@ export class DirectiveBinding extends ResolvedBinding {
callOnInit: hasLifecycleHook(LifecycleEvent.onInit, rb.key.token, ann),
callOnAllChangesDone: hasLifecycleHook(LifecycleEvent.onAllChangesDone, rb.key.token, ann),
changeDetection: ann instanceof Component ? ann.changeDetection : null,
changeDetection: ann instanceof ComponentMetadata ? ann.changeDetection : null,
exportAs: ann.exportAs
});
@ -264,7 +264,7 @@ export class DirectiveBinding extends ResolvedBinding {
return readAttributes;
}
static createFromType(type: Type, annotation: Directive): DirectiveBinding {
static createFromType(type: Type, annotation: DirectiveMetadata): DirectiveBinding {
var binding = new Binding(type, {toClass: type});
return DirectiveBinding.createFromBinding(binding, annotation);
}
@ -608,7 +608,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
if (dirDep.key.id === StaticKeys.instance().changeDetectorRefId) {
// We provide the component's view change detector to components and
// the surrounding component's change detector to directives.
if (dirBin.metadata.type === DirectiveMetadata.COMPONENT_TYPE) {
if (dirBin.metadata.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
var componentView = this._preBuiltObjects.view.getNestedView(
this._preBuiltObjects.elementRef.boundElementIndex);
return componentView.changeDetector.ref;
@ -713,7 +713,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
matched.forEach(s => queryRef.list.add(s));
}
private _createQueryRef(query: Query): void {
private _createQueryRef(query: QueryMetadata): void {
var queryList = new QueryList<any>();
if (isBlank(this._query0)) {
this._query0 = new QueryRef(query, queryList, this);
@ -726,7 +726,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
}
}
addDirectivesMatchingQuery(query: Query, list: any[]): void {
addDirectivesMatchingQuery(query: QueryMetadata, list: any[]): void {
var templateRef = this._preBuiltObjects.templateRef;
if (query.selector === TemplateRef && isPresent(templateRef)) {
list.push(templateRef);
@ -873,7 +873,7 @@ interface _ElementInjectorStrategy {
getComponent(): any;
isComponentKey(key: Key): boolean;
buildQueries(): void;
addDirectivesMatchingQuery(q: Query, res: any[]): void;
addDirectivesMatchingQuery(q: QueryMetadata, res: any[]): void;
getComponentBinding(): DirectiveBinding;
hydrate(): void;
dehydrate(): void;
@ -1006,7 +1006,7 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
}
}
addDirectivesMatchingQuery(query: Query, list: any[]): void {
addDirectivesMatchingQuery(query: QueryMetadata, list: any[]): void {
var i = this.injectorStrategy;
var p = i.protoStrategy;
@ -1112,7 +1112,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
}
}
addDirectivesMatchingQuery(query: Query, list: any[]): void {
addDirectivesMatchingQuery(query: QueryMetadata, list: any[]): void {
var ist = this.injectorStrategy;
var p = ist.protoStrategy;
@ -1144,7 +1144,7 @@ export class QueryError extends BaseException {
}
export class QueryRef {
constructor(public query: Query, public list: QueryList<any>,
constructor(public query: QueryMetadata, public list: QueryList<any>,
public originator: ElementInjector) {}
get isViewQuery(): boolean { return this.query.isViewQuery; }

View File

@ -1,10 +1,10 @@
import {resolveForwardRef, Injectable} from 'angular2/di';
import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
import {Pipe} from '../annotations_impl/annotations';
import {PipeMetadata} from '../metadata/directives';
import {reflector} from 'angular2/src/reflection/reflection';
/**
* Resolve a `Type` for {@link Pipe}.
* Resolve a `Type` for {@link PipeMetadata}.
*
* This interface can be overridden by the application developer to create custom behavior.
*
@ -13,14 +13,14 @@ import {reflector} from 'angular2/src/reflection/reflection';
@Injectable()
export class PipeResolver {
/**
* Return {@link Pipe} for a given `Type`.
* Return {@link PipeMetadata} for a given `Type`.
*/
resolve(type: Type): Pipe {
resolve(type: Type): PipeMetadata {
var metas = reflector.annotations(resolveForwardRef(type));
if (isPresent(metas)) {
for (var i = 0; i < metas.length; i++) {
var annotation = metas[i];
if (annotation instanceof Pipe) {
if (annotation instanceof PipeMetadata) {
return annotation;
}
}

View File

@ -18,7 +18,14 @@ import {
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
import {ProtoPipes} from 'angular2/src/core/pipes/pipes';
import * as renderApi from 'angular2/src/render/api';
import {
RenderDirectiveMetadata,
RenderElementBinder,
PropertyBindingType,
DirectiveBinder,
ProtoViewDto,
ViewType
} from 'angular2/src/render/api';
import {AppProtoView} from './view';
import {ElementBinder} from './element_binder';
import {ProtoElementInjector, DirectiveBinding} from './element_injector';
@ -26,8 +33,8 @@ import {ProtoElementInjector, DirectiveBinding} from './element_injector';
export class BindingRecordsCreator {
_directiveRecordsMap: Map<number, DirectiveRecord> = new Map();
getEventBindingRecords(elementBinders: List<renderApi.ElementBinder>,
allDirectiveMetadatas: renderApi.DirectiveMetadata[]): BindingRecord[] {
getEventBindingRecords(elementBinders: List<RenderElementBinder>,
allDirectiveMetadatas: RenderDirectiveMetadata[]): BindingRecord[] {
var res = [];
for (var boundElementIndex = 0; boundElementIndex < elementBinders.length;
boundElementIndex++) {
@ -41,16 +48,15 @@ export class BindingRecordsCreator {
}
private _createTemplateEventRecords(res: BindingRecord[],
renderElementBinder: renderApi.ElementBinder,
renderElementBinder: RenderElementBinder,
boundElementIndex: number): void {
renderElementBinder.eventBindings.forEach(eb => {
res.push(BindingRecord.createForEvent(eb.source, eb.fullName, boundElementIndex));
});
}
private _createHostEventRecords(res: BindingRecord[],
renderElementBinder: renderApi.ElementBinder,
allDirectiveMetadatas: renderApi.DirectiveMetadata[],
private _createHostEventRecords(res: BindingRecord[], renderElementBinder: RenderElementBinder,
allDirectiveMetadatas: RenderDirectiveMetadata[],
boundElementIndex: number): void {
for (var i = 0; i < renderElementBinder.directives.length; ++i) {
var dir = renderElementBinder.directives[i];
@ -63,9 +69,9 @@ export class BindingRecordsCreator {
}
getPropertyBindingRecords(textBindings: List<ASTWithSource>,
elementBinders: List<renderApi.ElementBinder>,
elementBinders: List<RenderElementBinder>,
allDirectiveMetadatas:
List<renderApi.DirectiveMetadata>): List<BindingRecord> {
List<RenderDirectiveMetadata>): List<BindingRecord> {
var bindings = [];
this._createTextNodeRecords(bindings, textBindings);
@ -80,9 +86,8 @@ export class BindingRecordsCreator {
return bindings;
}
getDirectiveRecords(elementBinders: List<renderApi.ElementBinder>,
allDirectiveMetadatas:
List<renderApi.DirectiveMetadata>): List<DirectiveRecord> {
getDirectiveRecords(elementBinders: List<RenderElementBinder>,
allDirectiveMetadatas: List<RenderDirectiveMetadata>): List<DirectiveRecord> {
var directiveRecords = [];
for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) {
@ -103,18 +108,18 @@ export class BindingRecordsCreator {
}
_createElementPropertyRecords(bindings: List<BindingRecord>, boundElementIndex: number,
renderElementBinder: renderApi.ElementBinder) {
renderElementBinder: RenderElementBinder) {
ListWrapper.forEach(renderElementBinder.propertyBindings, (binding) => {
if (binding.type === renderApi.PropertyBindingType.PROPERTY) {
if (binding.type === PropertyBindingType.PROPERTY) {
bindings.push(BindingRecord.createForElementProperty(binding.astWithSource,
boundElementIndex, binding.property));
} else if (binding.type === renderApi.PropertyBindingType.ATTRIBUTE) {
} else if (binding.type === PropertyBindingType.ATTRIBUTE) {
bindings.push(BindingRecord.createForElementAttribute(binding.astWithSource,
boundElementIndex, binding.property));
} else if (binding.type === renderApi.PropertyBindingType.CLASS) {
} else if (binding.type === PropertyBindingType.CLASS) {
bindings.push(BindingRecord.createForElementClass(binding.astWithSource, boundElementIndex,
binding.property));
} else if (binding.type === renderApi.PropertyBindingType.STYLE) {
} else if (binding.type === PropertyBindingType.STYLE) {
bindings.push(BindingRecord.createForElementStyle(binding.astWithSource, boundElementIndex,
binding.property, binding.unit));
}
@ -122,8 +127,8 @@ export class BindingRecordsCreator {
}
_createDirectiveRecords(bindings: List<BindingRecord>, boundElementIndex: number,
directiveBinders: List<renderApi.DirectiveBinder>,
allDirectiveMetadatas: List<renderApi.DirectiveMetadata>) {
directiveBinders: List<DirectiveBinder>,
allDirectiveMetadatas: List<RenderDirectiveMetadata>) {
for (var i = 0; i < directiveBinders.length; i++) {
var directiveBinder = directiveBinders[i];
var directiveMetadata = allDirectiveMetadatas[directiveBinder.directiveIndex];
@ -154,16 +159,16 @@ export class BindingRecordsCreator {
// host properties
ListWrapper.forEach(directiveBinder.hostPropertyBindings, (binding) => {
var dirIndex = new DirectiveIndex(boundElementIndex, i);
if (binding.type === renderApi.PropertyBindingType.PROPERTY) {
if (binding.type === PropertyBindingType.PROPERTY) {
bindings.push(BindingRecord.createForHostProperty(dirIndex, binding.astWithSource,
binding.property));
} else if (binding.type === renderApi.PropertyBindingType.ATTRIBUTE) {
} else if (binding.type === PropertyBindingType.ATTRIBUTE) {
bindings.push(BindingRecord.createForHostAttribute(dirIndex, binding.astWithSource,
binding.property));
} else if (binding.type === renderApi.PropertyBindingType.CLASS) {
} else if (binding.type === PropertyBindingType.CLASS) {
bindings.push(
BindingRecord.createForHostClass(dirIndex, binding.astWithSource, binding.property));
} else if (binding.type === renderApi.PropertyBindingType.STYLE) {
} else if (binding.type === PropertyBindingType.STYLE) {
bindings.push(BindingRecord.createForHostStyle(dirIndex, binding.astWithSource,
binding.property, binding.unit));
}
@ -172,7 +177,7 @@ export class BindingRecordsCreator {
}
_getDirectiveRecord(boundElementIndex: number, directiveIndex: number,
directiveMetadata: renderApi.DirectiveMetadata): DirectiveRecord {
directiveMetadata: RenderDirectiveMetadata): DirectiveRecord {
var id = boundElementIndex * 100 + directiveIndex;
if (!this._directiveRecordsMap.has(id)) {
@ -198,8 +203,7 @@ export class ProtoViewFactory {
*/
constructor(public _changeDetection: ChangeDetection) {}
createAppProtoViews(hostComponentBinding: DirectiveBinding,
rootRenderProtoView: renderApi.ProtoViewDto,
createAppProtoViews(hostComponentBinding: DirectiveBinding, rootRenderProtoView: ProtoViewDto,
allDirectives: List<DirectiveBinding>, pipes: PipeBinding[]): AppProtoView[] {
var allRenderDirectiveMetadata =
ListWrapper.map(allDirectives, directiveBinding => directiveBinding.metadata);
@ -233,8 +237,8 @@ export class ProtoViewFactory {
* for the given ProtoView and all nested ProtoViews.
*/
export function getChangeDetectorDefinitions(
hostComponentMetadata: renderApi.DirectiveMetadata, rootRenderProtoView: renderApi.ProtoViewDto,
allRenderDirectiveMetadata: List<renderApi.DirectiveMetadata>): List<ChangeDetectorDefinition> {
hostComponentMetadata: RenderDirectiveMetadata, rootRenderProtoView: ProtoViewDto,
allRenderDirectiveMetadata: List<RenderDirectiveMetadata>): List<ChangeDetectorDefinition> {
var nestedPvsWithIndex = _collectNestedProtoViews(rootRenderProtoView);
var nestedPvVariableNames = _collectNestedProtoViewsVariableNames(nestedPvsWithIndex);
return _getChangeDetectorDefinitions(hostComponentMetadata, nestedPvsWithIndex,
@ -242,7 +246,7 @@ export function getChangeDetectorDefinitions(
}
function _collectNestedProtoViews(
renderProtoView: renderApi.ProtoViewDto, parentIndex: number = null, boundElementIndex = null,
renderProtoView: ProtoViewDto, parentIndex: number = null, boundElementIndex = null,
result: List<RenderProtoViewWithIndex> = null): List<RenderProtoViewWithIndex> {
if (isBlank(result)) {
result = [];
@ -263,9 +267,9 @@ function _collectNestedProtoViews(
}
function _getChangeDetectorDefinitions(
hostComponentMetadata: renderApi.DirectiveMetadata,
hostComponentMetadata: RenderDirectiveMetadata,
nestedPvsWithIndex: List<RenderProtoViewWithIndex>, nestedPvVariableNames: List<List<string>>,
allRenderDirectiveMetadata: List<renderApi.DirectiveMetadata>): List<ChangeDetectorDefinition> {
allRenderDirectiveMetadata: List<RenderDirectiveMetadata>): List<ChangeDetectorDefinition> {
return ListWrapper.map(nestedPvsWithIndex, (pvWithIndex) => {
var elementBinders = pvWithIndex.renderProtoView.elementBinders;
var bindingRecordsCreator = new BindingRecordsCreator();
@ -277,10 +281,10 @@ function _getChangeDetectorDefinitions(
bindingRecordsCreator.getDirectiveRecords(elementBinders, allRenderDirectiveMetadata);
var strategyName = DEFAULT;
var typeString;
if (pvWithIndex.renderProtoView.type === renderApi.ViewType.COMPONENT) {
if (pvWithIndex.renderProtoView.type === ViewType.COMPONENT) {
strategyName = hostComponentMetadata.changeDetection;
typeString = 'comp';
} else if (pvWithIndex.renderProtoView.type === renderApi.ViewType.HOST) {
} else if (pvWithIndex.renderProtoView.type === ViewType.HOST) {
typeString = 'host';
} else {
typeString = 'embedded';
@ -293,7 +297,7 @@ function _getChangeDetectorDefinitions(
}
function _createAppProtoView(
renderProtoView: renderApi.ProtoViewDto, protoChangeDetector: ProtoChangeDetector,
renderProtoView: ProtoViewDto, protoChangeDetector: ProtoChangeDetector,
variableBindings: Map<string, string>, allDirectives: List<DirectiveBinding>,
pipes: PipeBinding[]): AppProtoView {
var elementBinders = renderProtoView.elementBinders;
@ -346,7 +350,7 @@ function _createVariableNames(parentVariableNames: List<string>, renderProtoView
return res;
}
export function createVariableLocations(elementBinders: List<renderApi.ElementBinder>):
export function createVariableLocations(elementBinders: List<RenderElementBinder>):
Map<string, number> {
var variableLocations = new Map();
for (var i = 0; i < elementBinders.length; i++) {
@ -368,7 +372,7 @@ function _createElementBinders(protoView, elementBinders, allDirectiveBindings)
ListWrapper.map(dirs, (dir) => allDirectiveBindings[dir.directiveIndex]);
var componentDirectiveBinding = null;
if (directiveBindings.length > 0) {
if (directiveBindings[0].metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
if (directiveBindings[0].metadata.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
componentDirectiveBinding = directiveBindings[0];
}
}
@ -439,7 +443,7 @@ function _createElementBinder(protoView: AppProtoView, boundElementIndex, render
return elBinder;
}
export function createDirectiveVariableBindings(renderElementBinder: renderApi.ElementBinder,
export function createDirectiveVariableBindings(renderElementBinder: RenderElementBinder,
directiveBindings: List<DirectiveBinding>):
Map<string, number> {
var directiveVariableBindings = new Map();
@ -478,7 +482,7 @@ function _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, e
function _directiveExportAs(directive): string {
var directiveExportAs = directive.metadata.exportAs;
if (isBlank(directiveExportAs) &&
directive.metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
directive.metadata.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
return "$implicit";
} else {
return directiveExportAs;
@ -486,7 +490,7 @@ function _directiveExportAs(directive): string {
}
class RenderProtoViewWithIndex {
constructor(public renderProtoView: renderApi.ProtoViewDto, public index: number,
constructor(public renderProtoView: ProtoViewDto, public index: number,
public parentIndex: number, public boundElementIndex: number) {}
}

View File

@ -1,5 +1,5 @@
import {Injectable} from 'angular2/di';
import {View} from 'angular2/src/core/annotations_impl/view';
import {ViewMetadata} from '../metadata/view';
import {Type, stringify, isBlank, BaseException} from 'angular2/src/facade/lang';
import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
@ -11,7 +11,7 @@ import {reflector} from 'angular2/src/reflection/reflection';
export class ViewResolver {
_cache: Map<Type, /*node*/ any> = new Map();
resolve(component: Type): View {
resolve(component: Type): ViewMetadata {
var view = this._cache.get(component);
if (isBlank(view)) {
@ -22,11 +22,11 @@ export class ViewResolver {
return view;
}
_resolve(component: Type): View {
_resolve(component: Type): ViewMetadata {
var annotations = reflector.annotations(component);
for (var i = 0; i < annotations.length; i++) {
var annotation = annotations[i];
if (annotation instanceof View) {
if (annotation instanceof ViewMetadata) {
return annotation;
}
}

View File

@ -0,0 +1,97 @@
library angular2.src.core.metadata;
import "package:angular2/src/facade/collection.dart" show List;
import "./metadata/di.dart";
import "./metadata/directives.dart";
import "./metadata/view.dart";
export "./metadata/di.dart";
export "./metadata/directives.dart";
export "./metadata/view.dart";
/**
* See: [DirectiveMetadata] for docs.
*/
class Directive extends DirectiveMetadata {
const Directive({String selector, List<String> properties,
List<String> events, Map<String, String> host,
List<LifecycleEvent> lifecycle, List bindings, String exportAs,
bool compileChildren: true})
: super(
selector: selector,
properties: properties,
events: events,
host: host,
lifecycle: lifecycle,
bindings: bindings,
exportAs: exportAs,
compileChildren: compileChildren);
}
/**
* See: [ComponentMetadata] for docs.
*/
class Component extends ComponentMetadata {
const Component({String selector, List<String> properties,
List<String> events, Map<String, String> host,
List<LifecycleEvent> lifecycle, List bindings, String exportAs,
bool compileChildren, List viewBindings, String changeDetection})
: super(
selector: selector,
properties: properties,
events: events,
host: host,
lifecycle: lifecycle,
bindings: bindings,
exportAs: exportAs,
compileChildren: compileChildren,
viewBindings: viewBindings,
changeDetection: changeDetection);
}
/**
* See: [ViewMetadata] for docs.
*/
class View extends ViewMetadata {
const View({String templateUrl, String template, dynamic directives,
dynamic pipes, ViewEncapsulation encapsulation, List<String> styles,
List<String> styleUrls})
: super(
templateUrl: templateUrl,
template: template,
directives: directives,
pipes: pipes,
encapsulation: encapsulation,
styles: styles,
styleUrls: styleUrls);
}
/**
* See: [PipeMetadata] for docs.
*/
class Pipe extends PipeMetadata {
const Pipe({name}) : super(name: name);
}
/**
* See: [AttributeMetadata] for docs.
*/
class Attribute extends AttributeMetadata {
const Attribute(String attributeName) : super(attributeName);
}
/**
* See: [QueryMetadata] for docs.
*/
class Query extends QueryMetadata {
const Query(dynamic /*Type | string*/ selector, {bool descendants: false})
: super(selector, descendants: descendants);
}
/**
* See: [ViewQueryMetadata] for docs.
*/
class ViewQuery extends ViewQueryMetadata {
const ViewQuery(dynamic /*Type | string*/ selector, {bool descendants: false})
: super(selector, descendants: descendants);
}

View File

@ -1,30 +1,57 @@
import {
ComponentAnnotation,
DirectiveAnnotation,
PipeAnnotation,
/**
* This indirection is needed to free up Component, etc symbols in the public API
* to be used by the decorator versions of these annotations.
*/
export {
QueryMetadata,
ViewQueryMetadata,
AttributeMetadata,
} from './metadata/di';
export {
ComponentMetadata,
DirectiveMetadata,
PipeMetadata,
LifecycleEvent
} from './annotations';
import {ViewAnnotation} from './view';
import {AttributeAnnotation, QueryAnnotation, ViewQueryAnnotation} from './di';
import {makeDecorator, makeParamDecorator, TypeDecorator, Class} from '../../util/decorators';
} from './metadata/directives';
export {ViewMetadata, ViewEncapsulation} from './metadata/view';
import {
QueryMetadata,
ViewQueryMetadata,
AttributeMetadata,
} from './metadata/di';
import {
ComponentMetadata,
DirectiveMetadata,
PipeMetadata,
LifecycleEvent
} from './metadata/directives';
import {ViewMetadata, ViewEncapsulation} from './metadata/view';
import {makeDecorator, makeParamDecorator, TypeDecorator, Class} from '../util/decorators';
import {Type} from 'angular2/src/facade/lang';
import {ViewEncapsulation} from 'angular2/src/render/api';
/**
* Interface for the {@link Directive} decorator function.
* Interface for the {@link DirectiveMetadata} decorator function.
*
* See {@link DirectiveFactory}.
*/
export interface DirectiveDecorator extends TypeDecorator {}
/**
* Interface for the {@link Component} decorator function.
* Interface for the {@link ComponentMetadata} decorator function.
*
* See {@link ComponentFactory}.
*/
export interface ComponentDecorator extends TypeDecorator {
/**
* Chain {@link View} annotation.
* Chain {@link ViewMetadata} annotation.
*/
View(obj: {
templateUrl?: string,
@ -38,13 +65,13 @@ export interface ComponentDecorator extends TypeDecorator {
}
/**
* Interface for the {@link View} decorator function.
* Interface for the {@link ViewMetadata} decorator function.
*
* See {@link ViewFactory}.
*/
export interface ViewDecorator extends TypeDecorator {
/**
* Chain {@link View} annotation.
* Chain {@link ViewMetadata} annotation.
*/
View(obj: {
templateUrl?: string,
@ -58,7 +85,7 @@ export interface ViewDecorator extends TypeDecorator {
}
/**
* {@link Directive} factory for creating annotations, decorators or DSL.
* {@link DirectiveMetadata} factory for creating annotations, decorators or DSL.
*
* ## Example as TypeScript Decorator
*
@ -107,7 +134,7 @@ export interface DirectiveFactory {
selector?: string, properties?: List<string>, events?: List<string>,
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>,
exportAs?: string, compileChildren?: boolean;
}): DirectiveAnnotation;
}): DirectiveMetadata;
}
/**
@ -177,7 +204,7 @@ export interface ComponentFactory {
compileChildren?: boolean,
viewBindings?: List<any>,
changeDetection?: string,
}): ComponentAnnotation;
}): ComponentMetadata;
}
/**
@ -239,11 +266,11 @@ export interface ViewFactory {
encapsulation?: ViewEncapsulation,
styles?: List<string>,
styleUrls?: List<string>,
}): ViewAnnotation;
}): ViewMetadata;
}
/**
* {@link Attribute} factory for creating annotations, decorators or DSL.
* {@link AttributeMetadata} factory for creating annotations, decorators or DSL.
*
* ## Example as TypeScript Decorator
*
@ -290,11 +317,11 @@ export interface ViewFactory {
*/
export interface AttributeFactory {
(name: string): TypeDecorator;
new (name: string): AttributeAnnotation;
new (name: string): AttributeMetadata;
}
/**
* {@link Query} factory for creating annotations, decorators or DSL.
* {@link QueryMetadata} factory for creating annotations, decorators or DSL.
*
* ## Example as TypeScript Decorator
*
@ -341,11 +368,11 @@ export interface AttributeFactory {
*/
export interface QueryFactory {
(selector: Type | string, {descendants}?: {descendants?: boolean}): ParameterDecorator;
new (selector: Type | string, {descendants}?: {descendants?: boolean}): QueryAnnotation;
new (selector: Type | string, {descendants}?: {descendants?: boolean}): QueryMetadata;
}
/**
* {@link Pipe} factory for creating decorators.
* {@link PipeMetadata} factory for creating decorators.
*
* ## Example as TypeScript Decorator
*
@ -370,38 +397,38 @@ export interface PipeFactory {
}
/**
* {@link Component} factory function.
* {@link ComponentMetadata} factory function.
*/
export var Component: ComponentFactory =
<ComponentFactory>makeDecorator(ComponentAnnotation, (fn: any) => fn.View = View);
<ComponentFactory>makeDecorator(ComponentMetadata, (fn: any) => fn.View = View);
/**
* {@link Directive} factory function.
* {@link DirectiveMetadata} factory function.
*/
export var Directive: DirectiveFactory = <DirectiveFactory>makeDecorator(DirectiveAnnotation);
export var Directive: DirectiveFactory = <DirectiveFactory>makeDecorator(DirectiveMetadata);
/**
* {@link View} factory function.
* {@link ViewMetadata} factory function.
*/
export var View: ViewFactory =
<ViewFactory>makeDecorator(ViewAnnotation, (fn: any) => fn.View = View);
<ViewFactory>makeDecorator(ViewMetadata, (fn: any) => fn.View = View);
/**
* {@link Attribute} factory function.
* {@link AttributeMetadata} factory function.
*/
export var Attribute: AttributeFactory = makeParamDecorator(AttributeAnnotation);
export var Attribute: AttributeFactory = makeParamDecorator(AttributeMetadata);
/**
* {@link Query} factory function.
* {@link QueryMetadata} factory function.
*/
export var Query: QueryFactory = makeParamDecorator(QueryAnnotation);
export var Query: QueryFactory = makeParamDecorator(QueryMetadata);
/**
* {@link ViewQuery} factory function.
* {@link ViewQueryMetadata} factory function.
*/
export var ViewQuery: QueryFactory = makeParamDecorator(ViewQueryAnnotation);
export var ViewQuery: QueryFactory = makeParamDecorator(ViewQueryMetadata);
/**
* {@link Pipe} factory function.
* {@link PipeMetadata} factory function.
*/
export var Pipe: PipeFactory = <PipeFactory>makeDecorator(PipeAnnotation);
export var Pipe: PipeFactory = <PipeFactory>makeDecorator(PipeMetadata);

View File

@ -29,7 +29,7 @@ import {resolveForwardRef} from 'angular2/di';
* ```
*/
@CONST()
export class Attribute extends DependencyMetadata {
export class AttributeMetadata extends DependencyMetadata {
constructor(public attributeName: string) { super(); }
get token() {
@ -49,7 +49,7 @@ export class Attribute extends DependencyMetadata {
* See {@link QueryList} for usage and example.
*/
@CONST()
export class Query extends DependencyMetadata {
export class QueryMetadata extends DependencyMetadata {
descendants: boolean;
constructor(private _selector: Type | string,
{descendants = false}: {descendants?: boolean} = {}) {
@ -74,7 +74,7 @@ export class Query extends DependencyMetadata {
* See {@link QueryList} for usage and example.
*/
@CONST()
export class ViewQuery extends Query {
export class ViewQueryMetadata extends QueryMetadata {
constructor(_selector: Type | string, {descendants = false}: {descendants?: boolean} = {}) {
super(_selector, {descendants: descendants});
}

View File

@ -6,7 +6,7 @@ import {DEFAULT} from 'angular2/change_detection';
/**
* Directives allow you to attach behavior to elements in the DOM.
*
* {@link Directive}s with an embedded view are called {@link Component}s.
* {@link DirectiveMetadata}s with an embedded view are called {@link ComponentMetadata}s.
*
* A directive consists of a single directive annotation and a controller class. When the
* directive's `selector` matches
@ -39,7 +39,7 @@ import {DEFAULT} from 'angular2/change_detection';
* current `ElementInjector` resolves the constructor dependencies for each directive.
*
* Angular then resolves dependencies as follows, according to the order in which they appear in the
* {@link View}:
* {@link ViewMetadata}:
*
* 1. Dependencies on the current element
* 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary
@ -64,7 +64,7 @@ import {DEFAULT} from 'angular2/change_detection';
* To inject element-specific special objects, declare the constructor parameter as:
* - `element: ElementRef` to obtain a reference to logical element in the view.
* - `viewContainer: ViewContainerRef` to control child template instantiation, for
* {@link Directive} directives only
* {@link DirectiveMetadata} directives only
* - `bindingPropagation: BindingPropagation` to control change detection in a more granular way.
*
* ## Example
@ -288,7 +288,7 @@ import {DEFAULT} from 'angular2/change_detection';
* location in the current view
* where these actions are performed.
*
* Views are always created as children of the current {@link View}, and as siblings of the
* Views are always created as children of the current {@link ViewMetadata}, and as siblings of the
* `<template>` element. Thus a
* directive in a child view cannot inject the directive that created it.
*
@ -378,7 +378,7 @@ import {DEFAULT} from 'angular2/change_detection';
* view occurs on the second `<li></li>` which is a sibling to the `<template>` element.
*/
@CONST()
export class Directive extends InjectableMetadata {
export class DirectiveMetadata extends InjectableMetadata {
/**
* The CSS selector that triggers the instantiation of a directive.
*
@ -422,7 +422,7 @@ export class Directive extends InjectableMetadata {
* - `directiveProperty` specifies the component property where the value is written.
* - `bindingProperty` specifies the DOM property where the value is read from.
*
* You can include a {@link Pipe} when specifying a `bindingProperty` to allow for data
* You can include a {@link PipeMetadata} when specifying a `bindingProperty` to allow for data
* transformation and structural change detection of the value. These pipes will be evaluated in
* the context of this component.
*
@ -768,7 +768,7 @@ export class Directive extends InjectableMetadata {
*
* All template expressions and statements are then evaluated against the component instance.
*
* For details on the `@View` annotation, see {@link View}.
* For details on the `@View` annotation, see {@link ViewMetadata}.
*
* ## Example
*
@ -790,7 +790,7 @@ export class Directive extends InjectableMetadata {
*
*/
@CONST()
export class Component extends Directive {
export class ComponentMetadata extends DirectiveMetadata {
/**
* Defines the used change detection strategy.
*
@ -884,7 +884,7 @@ export class Component extends Directive {
*/
export enum LifecycleEvent {
/**
* Notify a directive whenever a {@link View} that contains it is destroyed.
* Notify a directive whenever a {@link ViewMetadata} that contains it is destroyed.
*
* ## Example
*
@ -1022,7 +1022,7 @@ export enum LifecycleEvent {
* ```
*/
@CONST()
export class Pipe extends InjectableMetadata {
export class PipeMetadata extends InjectableMetadata {
name: string;
constructor({name}: {name: string}) {

View File

@ -13,7 +13,7 @@ export {ViewEncapsulation} from 'angular2/src/render/api';
* When a component is instantiated, the template is loaded into the component's shadow root, and
* the expressions and statements in the template are evaluated against the component.
*
* For details on the `@Component` annotation, see {@link Component}.
* For details on the `@Component` annotation, see {@link ComponentMetadata}.
*
* ## Example
*
@ -35,7 +35,7 @@ export {ViewEncapsulation} from 'angular2/src/render/api';
* ```
*/
@CONST()
export class View {
export class ViewMetadata {
/**
* Specifies a template URL for an angular component.
*

View File

@ -1,13 +1,13 @@
import {Type} from 'angular2/src/facade/lang';
import {Key, Dependency, ResolvedBinding, Binding} from 'angular2/di';
import {Pipe} from 'angular2/src/core/annotations_impl/annotations';
import {PipeMetadata} from '../metadata/directives';
export class PipeBinding extends ResolvedBinding {
constructor(public name: string, key: Key, factory: Function, dependencies: Dependency[]) {
super(key, factory, dependencies);
}
static createFromType(type: Type, metadata: Pipe): PipeBinding {
static createFromType(type: Type, metadata: PipeMetadata): PipeBinding {
var binding = new Binding(type, {toClass: type});
var rb = binding.resolve();
return new PipeBinding(metadata.name, rb.key, rb.factory, rb.dependencies);

View File

@ -5,7 +5,7 @@ import * as cd from 'angular2/src/change_detection/pipes';
export class ProtoPipes {
/**
* Map of {@link Pipe} names to {@link Pipe} implementations.
* Map of {@link PipeMetadata} names to {@link PipeMetadata} implementations.
*/
config: StringMap<string, PipeBinding> = {};

View File

@ -1,5 +1,5 @@
import {isPresent, isString, StringWrapper, isBlank} from 'angular2/src/facade/lang';
import {Directive, LifecycleEvent} from 'angular2/annotations';
import {Directive, LifecycleEvent} from 'angular2/metadata';
import {ElementRef} from 'angular2/core';
import {Renderer} from 'angular2/src/render/api';
import {

View File

@ -1,4 +1,4 @@
import {Directive, LifecycleEvent} from 'angular2/annotations';
import {Directive, LifecycleEvent} from 'angular2/metadata';
import {ViewContainerRef, ViewRef, TemplateRef} from 'angular2/core';
import {ChangeDetectorRef, IterableDiffer, IterableDiffers} from 'angular2/change_detection';
import {isPresent, isBlank} from 'angular2/src/facade/lang';

View File

@ -1,4 +1,4 @@
import {Directive} from 'angular2/annotations';
import {Directive} from 'angular2/metadata';
import {ViewContainerRef, TemplateRef} from 'angular2/core';
import {isBlank} from 'angular2/src/facade/lang';

View File

@ -1,4 +1,4 @@
import {Directive} from 'angular2/annotations';
import {Directive} from 'angular2/metadata';
/**
* The `NgNonBindable` directive tells Angular not to compile or bind the contents of the current

View File

@ -1,4 +1,4 @@
import {Directive, LifecycleEvent} from 'angular2/annotations';
import {Directive, LifecycleEvent} from 'angular2/metadata';
import {ElementRef} from 'angular2/core';
import {KeyValueDiffer, KeyValueDiffers} from 'angular2/change_detection';
import {isPresent, isBlank, print} from 'angular2/src/facade/lang';

View File

@ -1,4 +1,4 @@
import {Directive} from 'angular2/annotations';
import {Directive} from 'angular2/metadata';
import {Host} from 'angular2/di';
import {ViewContainerRef, TemplateRef} from 'angular2/core';
import {isPresent, isBlank, normalizeBlank, CONST_EXPR} from 'angular2/src/facade/lang';

View File

@ -1,5 +1,5 @@
import {Renderer} from 'angular2/render';
import {Directive} from 'angular2/annotations';
import {Directive} from 'angular2/metadata';
import {ElementRef} from 'angular2/core';
import {Self} from 'angular2/di';

View File

@ -1,5 +1,5 @@
import {Renderer} from 'angular2/render';
import {Directive} from 'angular2/annotations';
import {Directive} from 'angular2/metadata';
import {ElementRef} from 'angular2/core';
import {Self} from 'angular2/di';
import {NgControl} from './ng_control';

View File

@ -1,4 +1,4 @@
import {Directive, LifecycleEvent} from 'angular2/annotations';
import {Directive, LifecycleEvent} from 'angular2/metadata';
import {Inject, Host, SkipSelf, forwardRef, Binding} from 'angular2/di';
import {List, ListWrapper} from 'angular2/src/facade/collection';
import {CONST_EXPR} from 'angular2/src/facade/lang';

View File

@ -3,7 +3,7 @@ import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {List, StringMap} from 'angular2/src/facade/collection';
import {QueryList} from 'angular2/core';
import {Query, Directive, LifecycleEvent} from 'angular2/annotations';
import {Query, Directive, LifecycleEvent} from 'angular2/metadata';
import {forwardRef, Host, SkipSelf, Binding, Inject} from 'angular2/di';
import {ControlContainer} from './control_container';

View File

@ -6,7 +6,7 @@ import {
} from 'angular2/src/facade/async';
import {StringMapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/facade/lang';
import {Directive} from 'angular2/annotations';
import {Directive} from 'angular2/metadata';
import {forwardRef, Binding} from 'angular2/di';
import {NgControl} from './ng_control';
import {Form} from './form_interface';

View File

@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {QueryList} from 'angular2/core';
import {Query, Directive, LifecycleEvent} from 'angular2/annotations';
import {Query, Directive, LifecycleEvent} from 'angular2/metadata';
import {forwardRef, Binding} from 'angular2/di';
import {NgControl} from './ng_control';

View File

@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
import {List, ListWrapper} from 'angular2/src/facade/collection';
import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async';
import {Directive, LifecycleEvent} from 'angular2/annotations';
import {Directive, LifecycleEvent} from 'angular2/metadata';
import {forwardRef, Binding} from 'angular2/di';
import {NgControl} from './ng_control';
import {NgControlGroup} from './ng_control_group';

View File

@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {QueryList} from 'angular2/core';
import {Query, Directive, LifecycleEvent} from 'angular2/annotations';
import {Query, Directive, LifecycleEvent} from 'angular2/metadata';
import {forwardRef, Binding} from 'angular2/di';
import {NgControl} from './ng_control';

View File

@ -1,7 +1,7 @@
import {Renderer} from 'angular2/render';
import {ElementRef, QueryList} from 'angular2/core';
import {Self} from 'angular2/di';
import {Query, Directive} from 'angular2/annotations';
import {Query, Directive} from 'angular2/metadata';
import {NgControl} from './ng_control';
import {ControlValueAccessor} from './control_value_accessor';

View File

@ -1,6 +1,6 @@
import {forwardRef, Binding} from 'angular2/di';
import {CONST_EXPR} from 'angular2/src/facade/lang';
import {Directive} from 'angular2/annotations';
import {Directive} from 'angular2/metadata';
import {Validators} from '../validators';
export class NgValidator {

View File

@ -1,24 +1,24 @@
import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {Type, isPresent, BaseException, stringify, isBlank} from 'angular2/src/facade/lang';
import {View} from 'angular2/src/core/annotations_impl/view';
import {ViewMetadata} from '../core/metadata';
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
export class MockViewResolver extends ViewResolver {
_views: Map<Type, View> = new Map();
_views: Map<Type, ViewMetadata> = new Map();
_inlineTemplates: Map<Type, string> = new Map();
_viewCache: Map<Type, View> = new Map();
_viewCache: Map<Type, ViewMetadata> = new Map();
_directiveOverrides: Map<Type, Map<Type, Type>> = new Map();
constructor() { super(); }
/**
* Overrides the {@link View} for a component.
* Overrides the {@link ViewMetadata} for a component.
*
* @param {Type} component
* @param {ViewDefinition} view
*/
setView(component: Type, view: View): void {
setView(component: Type, view: ViewMetadata): void {
this._checkOverrideable(component);
this._views.set(component, view);
}
@ -35,7 +35,7 @@ export class MockViewResolver extends ViewResolver {
}
/**
* Overrides a directive from the component {@link View}.
* Overrides a directive from the component {@link ViewMetadata}.
*
* @param {Type} component
* @param {Type} from
@ -55,8 +55,8 @@ export class MockViewResolver extends ViewResolver {
}
/**
* Returns the {@link View} for a component:
* - Set the {@link View} to the overridden view when it exists or fallback to the default
* Returns the {@link ViewMetadata} for a component:
* - Set the {@link ViewMetadata} to the overridden view when it exists or fallback to the default
* `ViewResolver`,
* see `setView`.
* - Override the directives, see `overrideViewDirective`.
@ -65,7 +65,7 @@ export class MockViewResolver extends ViewResolver {
* @param component
* @returns {ViewDefinition}
*/
resolve(component: Type): View {
resolve(component: Type): ViewMetadata {
var view = this._viewCache.get(component);
if (isPresent(view)) return view;
@ -87,13 +87,14 @@ export class MockViewResolver extends ViewResolver {
}
directives[srcIndex] = to;
});
view = new View(
view = new ViewMetadata(
{template: view.template, templateUrl: view.templateUrl, directives: directives});
}
var inlineTemplate = this._inlineTemplates.get(component);
if (isPresent(inlineTemplate)) {
view = new View({template: inlineTemplate, templateUrl: null, directives: view.directives});
view = new ViewMetadata(
{template: inlineTemplate, templateUrl: null, directives: view.directives});
}
this._viewCache.set(component, view);

View File

@ -6,7 +6,7 @@ import {PipeTransform, PipeOnDestroy, WrappedValue} from 'angular2/change_detect
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {ChangeDetectorRef} from 'angular2/change_detection';
import {Pipe} from 'angular2/src/core/annotations/decorators';
import {Pipe} from '../core/metadata';
class ObservableStrategy {

View File

@ -15,7 +15,7 @@ import {StringMapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {Pipe} from 'angular2/src/core/annotations/decorators';
import {Pipe} from '../core/metadata';
// TODO: move to a global configable location along with other i18n components.
var defaultLocale: string = 'en-US';

View File

@ -3,7 +3,7 @@ import {Injectable} from 'angular2/di';
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
import {Pipe} from 'angular2/src/core/annotations/decorators';
import {Pipe} from '../core/metadata';
/**
* Implements json transforms to any object.

View File

@ -13,7 +13,7 @@ import {Injectable} from 'angular2/di';
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {Pipe} from 'angular2/src/core/annotations/decorators';
import {Pipe} from '../core/metadata';
/**
* Creates a new List or String containing only a prefix/suffix of the

View File

@ -5,7 +5,7 @@ import {PipeTransform, WrappedValue} from 'angular2/change_detection';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {Pipe} from 'angular2/src/core/annotations/decorators';
import {Pipe} from '../core/metadata';
/**
* Implements lowercase transforms to text.

View File

@ -16,7 +16,7 @@ import {ListWrapper} from 'angular2/src/facade/collection';
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {Pipe} from 'angular2/src/core/annotations/decorators';
import {Pipe} from '../core/metadata';
var defaultLocale: string = 'en-US';
var _re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');

View File

@ -4,7 +4,7 @@ import {Injectable} from 'angular2/di';
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
import {Pipe} from 'angular2/src/core/annotations/decorators';
import {Pipe} from '../core/metadata';
/**
* Implements uppercase transforms to text.

View File

@ -36,7 +36,7 @@ export class ElementPropertyBinding {
public property: string, public unit: string = null) {}
}
export class ElementBinder {
export class RenderElementBinder {
index: number;
parentIndex: number;
distanceToParent: number;
@ -110,7 +110,7 @@ export enum ViewType {
export class ProtoViewDto {
render: RenderProtoViewRef;
elementBinders: List<ElementBinder>;
elementBinders: List<RenderElementBinder>;
variableBindings: Map<string, string>;
type: ViewType;
textBindings: List<ASTWithSource>;
@ -119,7 +119,7 @@ export class ProtoViewDto {
constructor({render, elementBinders, variableBindings, type, textBindings,
transitiveNgContentCount}: {
render?: RenderProtoViewRef,
elementBinders?: List<ElementBinder>,
elementBinders?: List<RenderElementBinder>,
variableBindings?: Map<string, string>,
type?: ViewType,
textBindings?: List<ASTWithSource>,
@ -134,7 +134,7 @@ export class ProtoViewDto {
}
}
export class DirectiveMetadata {
export class RenderDirectiveMetadata {
static get DIRECTIVE_TYPE() { return 0; }
static get COMPONENT_TYPE() { return 1; }
id: any;
@ -220,7 +220,7 @@ export class DirectiveMetadata {
callOnAllChangesDone?: boolean,
changeDetection?: string,
exportAs?: string
}): DirectiveMetadata {
}): RenderDirectiveMetadata {
let hostListeners = new Map();
let hostProperties = new Map();
let hostAttributes = new Map();
@ -228,7 +228,7 @@ export class DirectiveMetadata {
if (isPresent(host)) {
MapWrapper.forEach(host, (value: string, key: string) => {
var matches = RegExpWrapper.firstMatch(DirectiveMetadata._hostRegExp, key);
var matches = RegExpWrapper.firstMatch(RenderDirectiveMetadata._hostRegExp, key);
if (isBlank(matches)) {
hostAttributes.set(key, value);
} else if (isPresent(matches[1])) {
@ -241,7 +241,7 @@ export class DirectiveMetadata {
});
}
return new DirectiveMetadata({
return new RenderDirectiveMetadata({
id: id,
selector: selector,
compileChildren: compileChildren,
@ -296,7 +296,7 @@ export class ViewDefinition {
componentId: string;
templateAbsUrl: string;
template: string;
directives: List<DirectiveMetadata>;
directives: List<RenderDirectiveMetadata>;
styleAbsUrls: List<string>;
styles: List<string>;
encapsulation: ViewEncapsulation;
@ -308,7 +308,7 @@ export class ViewDefinition {
template?: string,
styleAbsUrls?: List<string>,
styles?: List<string>,
directives?: List<DirectiveMetadata>,
directives?: List<RenderDirectiveMetadata>,
encapsulation?: ViewEncapsulation
} = {}) {
this.componentId = componentId;
@ -348,7 +348,7 @@ export class RenderCompiler {
/**
* Creats a ProtoViewDto that contains a single nested component with the given componentId.
*/
compileHost(directiveMetadata: DirectiveMetadata): Promise<ProtoViewDto> { return null; }
compileHost(directiveMetadata: RenderDirectiveMetadata): Promise<ProtoViewDto> { return null; }
/**
* Compiles a single DomProtoView. Non recursive so that

View File

@ -8,7 +8,7 @@ import {
ViewDefinition,
ProtoViewDto,
ViewType,
DirectiveMetadata,
RenderDirectiveMetadata,
RenderCompiler,
RenderProtoViewRef,
RenderProtoViewMergeMapping,
@ -50,7 +50,7 @@ export class DomCompiler extends RenderCompiler {
});
}
compileHost(directiveMetadata: DirectiveMetadata): Promise<ProtoViewDto> {
compileHost(directiveMetadata: RenderDirectiveMetadata): Promise<ProtoViewDto> {
let hostViewDef = new ViewDefinition({
componentId: directiveMetadata.id,
templateAbsUrl: null, template: null,

View File

@ -9,7 +9,7 @@ import {CompileStep} from './compile_step';
import {CompileElement} from './compile_element';
import {CompileControl} from './compile_control';
import {DirectiveMetadata} from '../../api';
import {RenderDirectiveMetadata} from '../../api';
import {dashCaseToCamelCase, camelCaseToDashCase, EVENT_TARGET_SEPARATOR} from '../util';
import {DirectiveBuilder, ElementBinderBuilder} from '../view/proto_view_builder';
@ -20,7 +20,7 @@ import {DirectiveBuilder, ElementBinderBuilder} from '../view/proto_view_builder
export class DirectiveParser implements CompileStep {
_selectorMatcher: SelectorMatcher = new SelectorMatcher();
constructor(public _parser: Parser, public _directives: List<DirectiveMetadata>) {
constructor(public _parser: Parser, public _directives: List<RenderDirectiveMetadata>) {
for (var i = 0; i < _directives.length; i++) {
var directive = _directives[i];
var selector = CssSelector.parse(directive.selector);
@ -48,7 +48,7 @@ export class DirectiveParser implements CompileStep {
var directive = this._directives[directiveIndex];
elementBinder = current.bindElement();
if (directive.type === DirectiveMetadata.COMPONENT_TYPE) {
if (directive.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
this._ensureHasOnlyOneComponent(elementBinder, current.elementDescription);
// components need to go first, so it is easier to locate them in the result.

View File

@ -1,12 +1,12 @@
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
import {isPresent, isArray} from 'angular2/src/facade/lang';
import {DirectiveMetadata} from 'angular2/src/render/api';
import {RenderDirectiveMetadata} from 'angular2/src/render/api';
/**
* Converts a [DirectiveMetadata] to a map representation. This creates a copy,
* that is, subsequent changes to `meta` will not be mirrored in the map.
*/
export function directiveMetadataToMap(meta: DirectiveMetadata): Map<string, any> {
export function directiveMetadataToMap(meta: RenderDirectiveMetadata): Map<string, any> {
return MapWrapper.createFromPairs([
['id', meta.id],
['selector', meta.selector],
@ -35,8 +35,8 @@ export function directiveMetadataToMap(meta: DirectiveMetadata): Map<string, any
* [DirectiveMetadata] object. This creates a copy, that is, subsequent changes
* to `map` will not be mirrored in the [DirectiveMetadata] object.
*/
export function directiveMetadataFromMap(map: Map<string, any>): DirectiveMetadata {
return new DirectiveMetadata({
export function directiveMetadataFromMap(map: Map<string, any>): RenderDirectiveMetadata {
return new RenderDirectiveMetadata({
id:<string>map.get('id'),
selector:<string>map.get('selector'),
compileChildren:<boolean>map.get('compileChildren'),

View File

@ -23,7 +23,16 @@ import {DomElementBinder, Event, HostAction} from './element_binder';
import {ElementSchemaRegistry} from '../schema/element_schema_registry';
import {TemplateCloner} from '../template_cloner';
import * as api from '../../api';
import {
ViewType,
ViewEncapsulation,
ProtoViewDto,
DirectiveBinder,
RenderElementBinder,
EventBinding,
ElementPropertyBinding,
PropertyBindingType
} from '../../api';
import {
NG_BINDING_CLASS,
@ -39,8 +48,8 @@ export class ProtoViewBuilder {
ngContentCount: number = 0;
hostAttributes: Map<string, string> = new Map();
constructor(public rootElement, public type: api.ViewType,
public viewEncapsulation: api.ViewEncapsulation) {}
constructor(public rootElement, public type: ViewType,
public viewEncapsulation: ViewEncapsulation) {}
bindElement(element: HTMLElement, description: string = null): ElementBinderBuilder {
var builder = new ElementBinderBuilder(this.elements.length, element, description);
@ -70,7 +79,7 @@ export class ProtoViewBuilder {
setHostAttribute(name: string, value: string) { this.hostAttributes.set(name, value); }
build(schemaRegistry: ElementSchemaRegistry, templateCloner: TemplateCloner): api.ProtoViewDto {
build(schemaRegistry: ElementSchemaRegistry, templateCloner: TemplateCloner): ProtoViewDto {
var domElementBinders = [];
var apiElementBinders = [];
@ -89,7 +98,7 @@ export class ProtoViewBuilder {
ebb.eventBuilder.merge(dbb.eventBuilder);
ListWrapper.forEach(dbb.templatePropertyNames,
(name) => directiveTemplatePropertyNames.add(name));
return new api.DirectiveBinder({
return new DirectiveBinder({
directiveIndex: dbb.directiveIndex,
propertyBindings: dbb.propertyBindings,
eventBindings: dbb.eventBindings,
@ -109,7 +118,7 @@ export class ProtoViewBuilder {
textNodeExpressions.push(expression);
textNodeIndices.push(nodeIndex);
});
apiElementBinders.push(new api.ElementBinder({
apiElementBinders.push(new RenderElementBinder({
index: ebb.index,
parentIndex: parentIndex,
distanceToParent: ebb.distanceToParent,
@ -132,7 +141,7 @@ export class ProtoViewBuilder {
}));
});
var rootNodeCount = DOM.childNodes(DOM.content(this.rootElement)).length;
return new api.ProtoViewDto({
return new ProtoViewDto({
render: new DomProtoViewRef(DomProtoView.create(
templateCloner, this.type, this.rootElement, this.viewEncapsulation, [rootNodeCount],
rootTextNodeIndices, domElementBinders, this.hostAttributes)),
@ -152,7 +161,7 @@ export class ElementBinderBuilder {
nestedProtoView: ProtoViewBuilder = null;
propertyBindings: Map<string, ASTWithSource> = new Map();
variableBindings: Map<string, string> = new Map();
eventBindings: List<api.EventBinding> = [];
eventBindings: List<EventBinding> = [];
eventBuilder: EventBuilder = new EventBuilder();
textBindings: Map<Node, ASTWithSource> = new Map();
readAttributes: Map<string, string> = new Map();
@ -185,7 +194,7 @@ export class ElementBinderBuilder {
throw new BaseException('Only one nested view per element is allowed');
}
this.nestedProtoView =
new ProtoViewBuilder(rootElement, api.ViewType.EMBEDDED, api.ViewEncapsulation.NONE);
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.NONE);
return this.nestedProtoView;
}
@ -230,7 +239,7 @@ export class DirectiveBuilder {
// property names used in the template
templatePropertyNames: List<string> = [];
hostPropertyBindings: Map<string, ASTWithSource> = new Map();
eventBindings: List<api.EventBinding> = [];
eventBindings: List<EventBinding> = [];
eventBuilder: EventBuilder = new EventBuilder();
constructor(public directiveIndex: number) {}
@ -261,14 +270,14 @@ export class EventBuilder extends AstTransformer {
constructor() { super(); }
add(name: string, source: ASTWithSource, target: string): api.EventBinding {
add(name: string, source: ASTWithSource, target: string): EventBinding {
// TODO(tbosch): reenable this when we are parsing element properties
// out of action expressions
// var adjustedAst = astWithSource.ast.visit(this);
var adjustedAst = source.ast;
var fullName = isPresent(target) ? target + EVENT_TARGET_SEPARATOR + name : name;
var result = new api.EventBinding(
fullName, new ASTWithSource(adjustedAst, source.source, source.location));
var result =
new EventBinding(fullName, new ASTWithSource(adjustedAst, source.source, source.location));
var event = new Event(name, target, fullName);
if (isBlank(target)) {
this.localEvents.push(event);
@ -331,7 +340,7 @@ const STYLE_PREFIX = 'style';
function buildElementPropertyBindings(
schemaRegistry: ElementSchemaRegistry, protoElement: /*element*/ any, isNgComponent: boolean,
bindingsInTemplate: Map<string, ASTWithSource>, directiveTemplatePropertyNames: Set<string>):
List<api.ElementPropertyBinding> {
List<ElementPropertyBinding> {
var propertyBindings = [];
MapWrapper.forEach(bindingsInTemplate, (ast, propertyNameInTemplate) => {
@ -361,8 +370,8 @@ function buildElementPropertyBindings(
function isValidElementPropertyBinding(schemaRegistry: ElementSchemaRegistry,
protoElement: /*element*/ any, isNgComponent: boolean,
binding: api.ElementPropertyBinding): boolean {
if (binding.type === api.PropertyBindingType.PROPERTY) {
binding: ElementPropertyBinding): boolean {
if (binding.type === PropertyBindingType.PROPERTY) {
if (!isNgComponent) {
return schemaRegistry.hasProperty(protoElement, binding.property);
} else {
@ -374,19 +383,19 @@ function isValidElementPropertyBinding(schemaRegistry: ElementSchemaRegistry,
}
function createElementPropertyBinding(schemaRegistry: ElementSchemaRegistry, ast: ASTWithSource,
propertyNameInTemplate: string): api.ElementPropertyBinding {
propertyNameInTemplate: string): ElementPropertyBinding {
var parts = StringWrapper.split(propertyNameInTemplate, PROPERTY_PARTS_SEPARATOR);
if (parts.length === 1) {
var propName = schemaRegistry.getMappedPropName(parts[0]);
return new api.ElementPropertyBinding(api.PropertyBindingType.PROPERTY, ast, propName);
return new ElementPropertyBinding(PropertyBindingType.PROPERTY, ast, propName);
} else if (parts[0] == ATTRIBUTE_PREFIX) {
return new api.ElementPropertyBinding(api.PropertyBindingType.ATTRIBUTE, ast, parts[1]);
return new ElementPropertyBinding(PropertyBindingType.ATTRIBUTE, ast, parts[1]);
} else if (parts[0] == CLASS_PREFIX) {
return new api.ElementPropertyBinding(api.PropertyBindingType.CLASS, ast,
return new ElementPropertyBinding(PropertyBindingType.CLASS, ast,
camelCaseToDashCase(parts[1]));
} else if (parts[0] == STYLE_PREFIX) {
var unit = parts.length > 2 ? parts[2] : null;
return new api.ElementPropertyBinding(api.PropertyBindingType.STYLE, ast, parts[1], unit);
return new ElementPropertyBinding(PropertyBindingType.STYLE, ast, parts[1], unit);
} else {
throw new BaseException(`Invalid property name ${propertyNameInTemplate}`);
}

View File

@ -1,4 +1,4 @@
import {Directive} from 'angular2/src/core/annotations/decorators';
import {Directive} from '../core/metadata';
import {List, StringMap, StringMapWrapper} from 'angular2/src/facade/collection';
import {Router} from './router';

View File

@ -2,7 +2,7 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {StringMapWrapper} from 'angular2/src/facade/collection';
import {isBlank, isPresent} from 'angular2/src/facade/lang';
import {Directive, Attribute} from 'angular2/src/core/annotations/decorators';
import {Directive, Attribute} from '../core/metadata';
import {DynamicComponentLoader, ComponentRef, ElementRef} from 'angular2/core';
import {Injector, bind, Dependency, UNDEFINED} from 'angular2/di';

View File

@ -4,7 +4,7 @@ import {Type, isPresent, BaseException, isBlank} from 'angular2/src/facade/lang'
import {Promise} from 'angular2/src/facade/async';
import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
import {View} from 'angular2/src/core/annotations_impl/view';
import {ViewMetadata} from '../core/metadata';
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
import {AppView} from 'angular2/src/core/compiler/view';
@ -48,7 +48,7 @@ var _nextRootElementId = 0;
@Injectable()
export class TestComponentBuilder {
_injector: Injector;
_viewOverrides: Map<Type, View>;
_viewOverrides: Map<Type, ViewMetadata>;
_directiveOverrides: Map<Type, Map<Type, Type>>;
_templateOverrides: Map<Type, string>;
@ -68,8 +68,8 @@ export class TestComponentBuilder {
}
/**
* Overrides only the html of a {@link Component}.
* All the other properties of the component's {@link View} are preserved.
* Overrides only the html of a {@link ComponentMetadata}.
* All the other properties of the component's {@link ViewMetadata} are preserved.
*
* @param {Type} component
* @param {string} html
@ -83,21 +83,21 @@ export class TestComponentBuilder {
}
/**
* Overrides a component's {@link View}.
* Overrides a component's {@link ViewMetadata}.
*
* @param {Type} component
* @param {view} View
*
* @return {TestComponentBuilder}
*/
overrideView(componentType: Type, view: View): TestComponentBuilder {
overrideView(componentType: Type, view: ViewMetadata): TestComponentBuilder {
var clone = this._clone();
clone._viewOverrides.set(componentType, view);
return clone;
}
/**
* Overrides the directives from the component {@link View}.
* Overrides the directives from the component {@link ViewMetadata}.
*
* @param {Type} component
* @param {Type} from

View File

@ -18,16 +18,11 @@ const INJECTABLES = const [
];
const DIRECTIVES = const [
const ClassDescriptor(
'Directive', 'package:angular2/src/core/annotations/annotations.dart',
const ClassDescriptor('Directive', 'package:angular2/src/core/metadatada/directive.dart',
superClass: 'Injectable'),
const ClassDescriptor(
'Directive', 'package:angular2/src/core/annotations/decorators.dart',
const ClassDescriptor('Directive', 'package:angular2/src/core/metadata.dart',
superClass: 'Injectable'),
const ClassDescriptor('Directive',
'package:angular2/src/core/annotations_impl/annotations.dart',
superClass: 'Injectable'),
const ClassDescriptor('Directive', 'package:angular2/annotations.dart',
const ClassDescriptor('Directive', 'package:angular2/metadata.dart',
superClass: 'Injectable'),
const ClassDescriptor('Directive', 'package:angular2/angular2.dart',
superClass: 'Injectable'),
@ -38,34 +33,26 @@ const DIRECTIVES = const [
];
const COMPONENTS = const [
const ClassDescriptor(
'Component', 'package:angular2/src/core/annotations/annotations.dart',
const ClassDescriptor('Component', 'package:angular2/src/core/metadata/directive.dart',
superClass: 'Directive'),
const ClassDescriptor(
'Component', 'package:angular2/src/core/annotations/decorators.dart',
const ClassDescriptor('Component', 'package:angular2/src/core/metadata.dart',
superClass: 'Directive'),
const ClassDescriptor('Component',
'package:angular2/src/core/annotations_impl/annotations.dart',
superClass: 'Directive'),
const ClassDescriptor('Component', 'package:angular2/annotations.dart',
const ClassDescriptor('Component', 'package:angular2/metadata.dart',
superClass: 'Directive'),
const ClassDescriptor('Component', 'package:angular2/angular2.dart',
superClass: 'Directive'),
const ClassDescriptor('Component', 'package:angular2/bootstrap_static.dart',
superClass: 'Directive'),
const ClassDescriptor('Component', 'package:angular2/core.dart',
superClass: 'Directive'),
superClass: '`Directive'),
];
const VIEWS = const [
const ClassDescriptor('View', 'package:angular2/view.dart'),
const ClassDescriptor('View', 'package:angular2/angular2.dart'),
const ClassDescriptor('View', 'package:angular2/bootstrap_static.dart'),
const ClassDescriptor('View', 'package:angular2/core.dart'),
const ClassDescriptor(
'View', 'package:angular2/src/core/annotations/view.dart'),
const ClassDescriptor(
'View', 'package:angular2/src/core/annotations_impl/view.dart'),
const ClassDescriptor('View', 'package:angular2/src/core/metadata/view.dart'),
const ClassDescriptor('View', 'package:angular2/src/core/metadata.dart'),
];
/// Checks if a given [Annotation] matches any of the given

View File

@ -4,10 +4,10 @@ import 'package:analyzer/analyzer.dart';
import 'package:analyzer/src/generated/element.dart';
import 'package:angular2/src/render/api.dart';
/// Reads [DirectiveMetadata] from the `node`. `node` is expected to be an
/// Reads [RenderDirectiveMetadata] from the `node`. `node` is expected to be an
/// instance of [Annotation], [NodeList<Annotation>], ListLiteral, or
/// [InstanceCreationExpression].
DirectiveMetadata readDirectiveMetadata(dynamic node) {
RenderDirectiveMetadata readDirectiveMetadata(dynamic node) {
assert(node is Annotation ||
node is NodeList ||
node is InstanceCreationExpression ||
@ -22,10 +22,10 @@ num _getDirectiveType(String annotationName, Element element) {
// TODO(kegluneq): Detect subtypes & implementations of `Directive`s.
switch (annotationName) {
case 'Directive':
byNameMatch = DirectiveMetadata.DIRECTIVE_TYPE;
byNameMatch = RenderDirectiveMetadata.DIRECTIVE_TYPE;
break;
case 'Component':
byNameMatch = DirectiveMetadata.COMPONENT_TYPE;
byNameMatch = RenderDirectiveMetadata.COMPONENT_TYPE;
break;
default:
return -1;
@ -34,8 +34,8 @@ num _getDirectiveType(String annotationName, Element element) {
var byResolvedAst = -1;
var libName = element.library.name;
// If we have resolved, ensure the library is correct.
if (libName == 'angular2.src.core.annotations.annotations' ||
libName == 'angular2.src.core.annotations_impl.annotations') {
if (libName == 'angular2.src.core.metadata.directives' ||
libName == 'angular2.src.core.metadata') {
byResolvedAst = byNameMatch;
}
// TODO(kegluneq): @keertip, can we expose this as a warning?
@ -45,7 +45,7 @@ num _getDirectiveType(String annotationName, Element element) {
}
/// Visitor responsible for processing the `annotations` property of a
/// [RegisterType] object and pulling out [DirectiveMetadata].
/// [RegisterType] object and pulling out [RenderDirectiveMetadata].
class _DirectiveMetadataVisitor extends Object
with RecursiveAstVisitor<Object> {
bool get _hasMeta => _type != null;
@ -87,7 +87,7 @@ class _DirectiveMetadataVisitor extends Object
_events = [];
}
DirectiveMetadata get meta => DirectiveMetadata.create(
RenderDirectiveMetadata get meta => RenderDirectiveMetadata.create(
type: _type,
selector: _selector,
compileChildren: _compileChildren,

View File

@ -11,32 +11,32 @@ export 'class_matcher_base.dart' show ClassDescriptor;
/// covers all libraries which provide them.
const _ON_CHANGE_INTERFACES = const [
const ClassDescriptor('OnChange', 'package:angular2/angular2.dart'),
const ClassDescriptor('OnChange', 'package:angular2/annotations.dart'),
const ClassDescriptor('OnChange', 'package:angular2/metadata.dart'),
const ClassDescriptor(
'OnChange', 'package:angular2/src/core/compiler/interfaces.dart'),
];
const _ON_DESTROY_INTERFACES = const [
const ClassDescriptor('OnDestroy', 'package:angular2/angular2.dart'),
const ClassDescriptor('OnDestroy', 'package:angular2/annotations.dart'),
const ClassDescriptor('OnDestroy', 'package:angular2/metadata.dart'),
const ClassDescriptor(
'OnDestroy', 'package:angular2/src/core/compiler/interfaces.dart'),
];
const _ON_CHECK_INTERFACES = const [
const ClassDescriptor('OnCheck', 'package:angular2/angular2.dart'),
const ClassDescriptor('OnCheck', 'package:angular2/annotations.dart'),
const ClassDescriptor('OnCheck', 'package:angular2/metadata.dart'),
const ClassDescriptor(
'OnCheck', 'package:angular2/src/core/compiler/interfaces.dart'),
];
const _ON_INIT_INTERFACES = const [
const ClassDescriptor('OnInit', 'package:angular2/angular2.dart'),
const ClassDescriptor('OnInit', 'package:angular2/annotations.dart'),
const ClassDescriptor('OnInit', 'package:angular2/metadata.dart'),
const ClassDescriptor(
'OnInit', 'package:angular2/src/core/compiler/interfaces.dart'),
];
const _ON_ALL_CHANGES_DONE_INTERFACES = const [
const ClassDescriptor('OnAllChangesDone', 'package:angular2/angular2.dart'),
const ClassDescriptor(
'OnAllChangesDone', 'package:angular2/annotations.dart'),
'OnAllChangesDone', 'package:angular2/metadata.dart'),
const ClassDescriptor(
'OnAllChangesDone', 'package:angular2/src/core/compiler/interfaces.dart')
];

View File

@ -20,7 +20,7 @@ import 'logging.dart';
/// easier.
class NgMeta {
/// Directive metadata for each type annotated as a directive.
final Map<String, DirectiveMetadata> types;
final Map<String, RenderDirectiveMetadata> types;
/// List of other types and names associated with a given name.
final Map<String, List<String>> aliases;
@ -66,7 +66,7 @@ class NgMeta {
}
/// Returns the metadata for every type associated with the given [alias].
List<DirectiveMetadata> flatten(String alias) {
List<RenderDirectiveMetadata> flatten(String alias) {
var result = [];
var seen = new Set();
helper(name) {

View File

@ -23,7 +23,7 @@ class RegisteredType {
/// The annotations registered.
final Expression annotations;
DirectiveMetadata _directiveMetadata = null;
RenderDirectiveMetadata _directiveMetadata = null;
RegisteredType._(this.typeName, this.registerMethod, this.factoryFn,
this.parameters, this.annotations);
@ -37,7 +37,7 @@ class RegisteredType {
visitor.factoryFn, visitor.parameters, visitor.annotations);
}
DirectiveMetadata get directiveMetadata {
RenderDirectiveMetadata get directiveMetadata {
if (_directiveMetadata == null) {
try {
_directiveMetadata = readDirectiveMetadata(annotations);

View File

@ -3,7 +3,7 @@ library angular2.transform.directive_processor.visitors;
import 'dart:async';
import 'package:analyzer/analyzer.dart';
import 'package:analyzer/src/generated/java_core.dart';
import 'package:angular2/annotations.dart' show LifecycleEvent;
import 'package:angular2/metadata.dart' show LifecycleEvent;
import 'package:angular2/src/render/xhr.dart' show XHR;
import 'package:angular2/src/transform/common/annotation_matcher.dart';
import 'package:angular2/src/transform/common/async_string_writer.dart';

View File

@ -27,7 +27,7 @@ class ViewDefinitionResults {
}
class ViewDefinitionEntry {
final DirectiveMetadata hostMetadata;
final RenderDirectiveMetadata hostMetadata;
final ViewDefinition viewDef;
ViewDefinitionEntry._(this.hostMetadata, this.viewDef);
@ -113,7 +113,7 @@ class _ViewDefinitionCreator {
/// Reads the `.ng_meta.json` files associated with all of `entryPoint`'s
/// imports and creates a map `Type` name, prefixed if appropriate to the
/// associated [DirectiveMetadata].
/// associated [RenderDirectiveMetadata].
///
/// For example, if in `entryPoint` we have:
///
@ -129,13 +129,13 @@ class _ViewDefinitionCreator {
/// ```
///
/// This method will look for `component.ng_meta.json`to contain the
/// serialized [DirectiveMetadata] for `MyComponent` and any other
/// serialized [RenderDirectiveMetadata] for `MyComponent` and any other
/// `Directive`s declared in `component.dart`. We use this information to
/// build a map:
///
/// ```
/// {
/// "prefix.MyComponent": [DirectiveMetadata for MyComponent],
/// "prefix.MyComponent": [RenderDirectiveMetadata for MyComponent],
/// ...<any other entries>...
/// }
/// ```
@ -184,7 +184,7 @@ class _TemplateExtractVisitor extends Object with RecursiveAstVisitor<Object> {
@override
Object visitInstanceCreationExpression(InstanceCreationExpression node) {
if (_isViewAnnotation(node)) {
viewDef = new ViewDefinition(directives: <DirectiveMetadata>[]);
viewDef = new ViewDefinition(directives: <RenderDirectiveMetadata>[]);
node.visitChildren(this);
}
return null;

View File

@ -1 +1 @@
library util_decorators;
library angular2.core.util.decorators;

View File

@ -53,7 +53,7 @@ export interface TypeDecorator {
// ParameterDecorator is declared in lib.d.ts as a `declare type`
// so we cannot declare this interface as a subtype.
// see https://github.com/angular/angular/issues/3379#issuecomment-126169417
(target: Object, propertyKey: string | symbol, parameterIndex: number): void;
(target: Object, propertyKey?: string | symbol, parameterIndex?: number): void;
/**
* Storage for the accumulated annotations so far used by the DSL syntax.

View File

@ -16,8 +16,8 @@ import {
} from "angular2/src/facade/collection";
import {
ProtoViewDto,
DirectiveMetadata,
ElementBinder,
RenderDirectiveMetadata,
RenderElementBinder,
DirectiveBinder,
ElementPropertyBinding,
EventBinding,
@ -85,9 +85,9 @@ export class Serializer {
return this._serializeDirectiveBinder(obj);
} else if (type == ProtoViewDto) {
return this._serializeProtoViewDto(obj);
} else if (type == ElementBinder) {
} else if (type == RenderElementBinder) {
return this._serializeElementBinder(obj);
} else if (type == DirectiveMetadata) {
} else if (type == RenderDirectiveMetadata) {
return this._serializeDirectiveMetadata(obj);
} else if (type == ASTWithSource) {
return this._serializeASTWithSource(obj);
@ -129,9 +129,9 @@ export class Serializer {
return this._deserializeDirectiveBinder(map);
} else if (type == ProtoViewDto) {
return this._deserializeProtoViewDto(map);
} else if (type == DirectiveMetadata) {
} else if (type == RenderDirectiveMetadata) {
return this._deserializeDirectiveMetadata(map);
} else if (type == ElementBinder) {
} else if (type == RenderElementBinder) {
return this._deserializeElementBinder(map);
} else if (type == ASTWithSource) {
return this._deserializeASTWithSource(map, data);
@ -271,7 +271,7 @@ export class Serializer {
'componentId': view.componentId,
'templateAbsUrl': view.templateAbsUrl,
'template': view.template,
'directives': this.serialize(view.directives, DirectiveMetadata),
'directives': this.serialize(view.directives, RenderDirectiveMetadata),
'styleAbsUrls': view.styleAbsUrls,
'styles': view.styles,
'encapsulation': serializeEnum(view.encapsulation)
@ -282,7 +282,7 @@ export class Serializer {
return new ViewDefinition({
componentId: obj['componentId'],
templateAbsUrl: obj['templateAbsUrl'], template: obj['template'],
directives: this.deserialize(obj['directives'], DirectiveMetadata),
directives: this.deserialize(obj['directives'], RenderDirectiveMetadata),
styleAbsUrls: obj['styleAbsUrls'],
styles: obj['styles'],
encapsulation:
@ -308,7 +308,7 @@ export class Serializer {
});
}
private _serializeElementBinder(binder: ElementBinder): Object {
private _serializeElementBinder(binder: RenderElementBinder): Object {
return {
'index': binder.index,
'parentIndex': binder.parentIndex,
@ -322,8 +322,8 @@ export class Serializer {
};
}
private _deserializeElementBinder(obj: StringMap<string, any>): ElementBinder {
return new ElementBinder({
private _deserializeElementBinder(obj: StringMap<string, any>): RenderElementBinder {
return new RenderElementBinder({
index: obj['index'],
parentIndex: obj['parentIndex'],
distanceToParent: obj['distanceToParent'],
@ -339,7 +339,7 @@ export class Serializer {
private _serializeProtoViewDto(view: ProtoViewDto): Object {
return {
'render': this._protoViewStore.serialize(view.render),
'elementBinders': this.serialize(view.elementBinders, ElementBinder),
'elementBinders': this.serialize(view.elementBinders, RenderElementBinder),
'variableBindings': this.mapToObject(view.variableBindings),
'type': serializeEnum(view.type),
'textBindings': this.serialize(view.textBindings, ASTWithSource),
@ -350,7 +350,7 @@ export class Serializer {
private _deserializeProtoViewDto(obj: StringMap<string, any>): ProtoViewDto {
return new ProtoViewDto({
render: this._protoViewStore.deserialize(obj["render"]),
elementBinders: this.deserialize(obj['elementBinders'], ElementBinder),
elementBinders: this.deserialize(obj['elementBinders'], RenderElementBinder),
variableBindings: this.objectToMap(obj['variableBindings']),
textBindings: this.deserialize(obj['textBindings'], ASTWithSource, "interpolation"),
type: deserializeEnum(obj['type'], this._enumRegistry.get(ViewType)),
@ -358,7 +358,7 @@ export class Serializer {
});
}
private _serializeDirectiveMetadata(meta: DirectiveMetadata): Object {
private _serializeDirectiveMetadata(meta: RenderDirectiveMetadata): Object {
var obj = {
'id': meta.id,
'selector': meta.selector,
@ -381,8 +381,8 @@ export class Serializer {
};
return obj;
}
private _deserializeDirectiveMetadata(obj: StringMap<string, any>): DirectiveMetadata {
return new DirectiveMetadata({
private _deserializeDirectiveMetadata(obj: StringMap<string, any>): RenderDirectiveMetadata {
return new RenderDirectiveMetadata({
id: obj['id'],
selector: obj['selector'],
compileChildren: obj['compileChildren'],

View File

@ -9,7 +9,7 @@ import {createInjector} from "./di_bindings";
import {
Renderer,
RenderCompiler,
DirectiveMetadata,
RenderDirectiveMetadata,
ProtoViewDto,
ViewDefinition,
RenderProtoViewRef,
@ -94,7 +94,7 @@ export class WebWorkerMain {
var promise: Promise<any>;
switch (data.method) {
case "compileHost":
var directiveMetadata = this._serializer.deserialize(data.args[0], DirectiveMetadata);
var directiveMetadata = this._serializer.deserialize(data.args[0], RenderDirectiveMetadata);
promise = this._renderCompiler.compileHost(directiveMetadata);
this._wrapWebWorkerPromise(data.id, promise, ProtoViewDto);
break;

View File

@ -1,7 +1,7 @@
import {
Renderer,
RenderCompiler,
DirectiveMetadata,
RenderDirectiveMetadata,
ProtoViewDto,
ViewDefinition,
RenderProtoViewRef,
@ -28,8 +28,8 @@ export class WebWorkerCompiler implements RenderCompiler {
/**
* Creats a ProtoViewDto that contains a single nested component with the given componentId.
*/
compileHost(directiveMetadata: DirectiveMetadata): Promise<ProtoViewDto> {
var fnArgs: List<FnArg> = [new FnArg(directiveMetadata, DirectiveMetadata)];
compileHost(directiveMetadata: RenderDirectiveMetadata): Promise<ProtoViewDto> {
var fnArgs: List<FnArg> = [new FnArg(directiveMetadata, RenderDirectiveMetadata)];
var args: UiArguments = new UiArguments("compiler", "compileHost", fnArgs);
return this._messageBroker.runOnUiThread(args, ProtoViewDto);
}

View File

@ -25,7 +25,7 @@ const aContents = '''
library bar.ng_deps.dart;
import 'bar.dart';
import 'package:angular2/src/core/annotations/annotations.dart';
import 'package:angular2/src/core/metadata.dart';
bool _visited = false;
void initReflector(reflector) {

View File

@ -41,7 +41,7 @@ const bContents = '''
library b.ng_deps.dart;
import 'b.dart';
import 'package:angular2/src/core/annotations/annotations.dart';
import 'package:angular2/src/core/metadata.dart';
bool _visited = false;
void initReflector(reflector) {
@ -60,7 +60,7 @@ const cContents = '''
library c.ng_deps.dart;
import 'c.dart';
import 'package:angular2/src/core/annotations/annotations.dart';
import 'package:angular2/src/core/metadata.dart';
import 'b.dart' as dep;
bool _visited = false;

View File

@ -24,7 +24,7 @@ Future runBenchmark() async {
const aContents = '''
library dinner.soup;
import 'package:angular2/src/core/annotations/annotations.dart';
import 'package:angular2/src/core/metadata.dart';
@Component(selector: '[soup]')
class SoupComponent {

View File

@ -12,7 +12,7 @@ import {
} from 'angular2/test_lib';
import {isPresent, stringify} from 'angular2/src/facade/lang';
import {bootstrap, ApplicationRef} from 'angular2/src/core/application';
import {Component, Directive, View} from 'angular2/annotations';
import {Component, Directive, View} from 'angular2/metadata';
import {DOM} from 'angular2/src/dom/dom_adapter';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {bind, Inject, Injector} from 'angular2/di';

View File

@ -22,8 +22,7 @@ import {AppProtoView} from 'angular2/src/core/compiler/view';
import {ElementBinder} from 'angular2/src/core/compiler/element_binder';
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
import {PipeResolver} from 'angular2/src/core/compiler/pipe_resolver';
import {Attribute, View, Component, Directive, Pipe} from 'angular2/annotations';
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
import {Attribute, ViewMetadata, Component, Directive, Pipe} from 'angular2/metadata';
import {internalProtoView} from 'angular2/src/core/compiler/view_ref';
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
@ -35,7 +34,16 @@ import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
import {UrlResolver} from 'angular2/src/services/url_resolver';
import {AppRootUrl} from 'angular2/src/services/app_root_url';
import * as renderApi from 'angular2/src/render/api';
import {
ProtoViewDto,
ViewType,
RenderProtoViewRef,
ViewDefinition,
RenderProtoViewMergeMapping,
RenderDirectiveMetadata,
DirectiveBinder,
RenderElementBinder
} from 'angular2/src/render/api';
// TODO(tbosch): Spys don't support named modules...
import {RenderCompiler} from 'angular2/src/render/api';
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
@ -48,8 +56,7 @@ export function main() {
cmpUrlMapper, rootProtoView;
var renderCompileRequests: any[];
function createCompiler(renderCompileResults:
List<renderApi.ProtoViewDto | Promise<renderApi.ProtoViewDto>>,
function createCompiler(renderCompileResults: List<ProtoViewDto | Promise<ProtoViewDto>>,
protoViewFactoryResults: List<AppProtoView>) {
var urlResolver = new UrlResolver();
renderCompileRequests = [];
@ -73,12 +80,12 @@ export function main() {
renderCompiler = new SpyRenderCompiler();
renderCompiler.spy('compileHost')
.andCallFake((componentId) => {
return PromiseWrapper.resolve(createRenderProtoView(
[createRenderComponentElementBinder(0)], renderApi.ViewType.HOST));
return PromiseWrapper.resolve(
createRenderProtoView([createRenderComponentElementBinder(0)], ViewType.HOST));
});
renderCompiler.spy('mergeProtoViewsRecursively')
.andCallFake((protoViewRefs: List<renderApi.RenderProtoViewRef | List<any>>) => {
return PromiseWrapper.resolve(new renderApi.RenderProtoViewMergeMapping(
.andCallFake((protoViewRefs: List<RenderProtoViewRef | List<any>>) => {
return PromiseWrapper.resolve(new RenderProtoViewMergeMapping(
new MergedRenderProtoViewRef(protoViewRefs), 1, [], 0, [], [], [null]));
});
// TODO spy on .compile and return RenderProtoViewRef, same for compileHost
@ -87,7 +94,7 @@ export function main() {
describe('serialize template', () => {
function captureTemplate(template: viewAnn.View): Promise<renderApi.ViewDefinition> {
function captureTemplate(template: ViewMetadata): Promise<ViewDefinition> {
tplResolver.setView(MainComponent, template);
var compiler =
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
@ -98,8 +105,8 @@ export function main() {
});
}
function captureDirective(directive): Promise<renderApi.DirectiveMetadata> {
return captureTemplate(new viewAnn.View({template: '<div></div>', directives: [directive]}))
function captureDirective(directive): Promise<RenderDirectiveMetadata> {
return captureTemplate(new ViewMetadata({template: '<div></div>', directives: [directive]}))
.then((renderTpl) => {
expect(renderTpl.directives.length).toBe(1);
return renderTpl.directives[0];
@ -107,7 +114,7 @@ export function main() {
}
it('should fill the componentId', inject([AsyncTestCompleter], (async) => {
captureTemplate(new viewAnn.View({template: '<div></div>'}))
captureTemplate(new ViewMetadata({template: '<div></div>'}))
.then((renderTpl) => {
expect(renderTpl.componentId).toEqual(stringify(MainComponent));
async.done();
@ -115,7 +122,7 @@ export function main() {
}));
it('should fill inline template', inject([AsyncTestCompleter], (async) => {
captureTemplate(new viewAnn.View({template: '<div></div>'}))
captureTemplate(new ViewMetadata({template: '<div></div>'}))
.then((renderTpl) => {
expect(renderTpl.template).toEqual('<div></div>');
async.done();
@ -125,7 +132,7 @@ export function main() {
it('should fill templateAbsUrl given inline templates',
inject([AsyncTestCompleter], (async) => {
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
captureTemplate(new viewAnn.View({template: '<div></div>'}))
captureTemplate(new ViewMetadata({template: '<div></div>'}))
.then((renderTpl) => {
expect(renderTpl.templateAbsUrl).toEqual('http://www.app.com/cmp/main.js');
async.done();
@ -135,7 +142,7 @@ export function main() {
it('should not fill templateAbsUrl given no inline template or template url',
inject([AsyncTestCompleter], (async) => {
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
captureTemplate(new viewAnn.View({template: null, templateUrl: null}))
captureTemplate(new ViewMetadata({template: null, templateUrl: null}))
.then((renderTpl) => {
expect(renderTpl.templateAbsUrl).toBe(null);
async.done();
@ -144,7 +151,7 @@ export function main() {
it('should fill templateAbsUrl given url template', inject([AsyncTestCompleter], (async) => {
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
captureTemplate(new viewAnn.View({templateUrl: 'tpl/main.html'}))
captureTemplate(new ViewMetadata({templateUrl: 'tpl/main.html'}))
.then((renderTpl) => {
expect(renderTpl.templateAbsUrl).toEqual('http://www.app.com/cmp/tpl/main.html');
async.done();
@ -153,7 +160,7 @@ export function main() {
it('should fill styleAbsUrls given styleUrls', inject([AsyncTestCompleter], (async) => {
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
captureTemplate(new viewAnn.View({styleUrls: ['css/1.css', 'css/2.css']}))
captureTemplate(new ViewMetadata({styleUrls: ['css/1.css', 'css/2.css']}))
.then((renderTpl) => {
expect(renderTpl.styleAbsUrls)
.toEqual(
@ -181,7 +188,7 @@ export function main() {
it('should fill directive.type for components', inject([AsyncTestCompleter], (async) => {
captureDirective(MainComponent)
.then((renderDir) => {
expect(renderDir.type).toEqual(renderApi.DirectiveMetadata.COMPONENT_TYPE);
expect(renderDir.type).toEqual(RenderDirectiveMetadata.COMPONENT_TYPE);
async.done();
});
}));
@ -190,7 +197,7 @@ export function main() {
inject([AsyncTestCompleter], (async) => {
captureDirective(SomeDynamicComponentDirective)
.then((renderDir) => {
expect(renderDir.type).toEqual(renderApi.DirectiveMetadata.COMPONENT_TYPE);
expect(renderDir.type).toEqual(RenderDirectiveMetadata.COMPONENT_TYPE);
async.done();
});
}));
@ -199,7 +206,7 @@ export function main() {
inject([AsyncTestCompleter], (async) => {
captureDirective(SomeDirective)
.then((renderDir) => {
expect(renderDir.type).toEqual(renderApi.DirectiveMetadata.DIRECTIVE_TYPE);
expect(renderDir.type).toEqual(RenderDirectiveMetadata.DIRECTIVE_TYPE);
async.done();
});
}));
@ -269,7 +276,7 @@ export function main() {
describe('call ProtoViewFactory', () => {
it('should pass the ProtoViewDto', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var renderProtoView = createRenderProtoView();
var expectedProtoView = createProtoView();
var compiler = createCompiler([renderProtoView], [rootProtoView, expectedProtoView]);
@ -282,7 +289,7 @@ export function main() {
}));
it('should pass the component binding', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var compiler =
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
compiler.compileInHost(MainComponent)
@ -296,7 +303,7 @@ export function main() {
it('should pass the directive bindings', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(
MainComponent,
new viewAnn.View({template: '<div></div>', directives: [SomeDirective]}));
new ViewMetadata({template: '<div></div>', directives: [SomeDirective]}));
var compiler =
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
compiler.compileInHost(MainComponent)
@ -310,7 +317,7 @@ export function main() {
it('should pass the pipe bindings', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent,
new viewAnn.View({template: '<div></div>', pipes: [SomePipe]}));
new ViewMetadata({template: '<div></div>', pipes: [SomePipe]}));
var compiler =
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
compiler.compileInHost(MainComponent)
@ -324,7 +331,7 @@ export function main() {
it('should use the protoView of the ProtoViewFactory',
inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var compiler =
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
compiler.compileInHost(MainComponent)
@ -337,8 +344,8 @@ export function main() {
});
it('should load nested components', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(NestedComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
tplResolver.setView(NestedComponent, new ViewMetadata({template: '<div></div>'}));
var mainProtoView =
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]);
var nestedProtoView = createProtoView();
@ -361,17 +368,16 @@ export function main() {
}));
it('should load nested components in viewcontainers', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(NestedComponent, new viewAnn.View({template: '<div></div>'}));
var viewportProtoView =
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)],
renderApi.ViewType.EMBEDDED);
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
tplResolver.setView(NestedComponent, new ViewMetadata({template: '<div></div>'}));
var viewportProtoView = createProtoView(
[createComponentElementBinder(directiveResolver, NestedComponent)], ViewType.EMBEDDED);
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
var nestedProtoView = createProtoView();
var renderPvDtos = [
createRenderProtoView([
createRenderViewportElementBinder(createRenderProtoView(
[createRenderComponentElementBinder(0)], renderApi.ViewType.EMBEDDED))
createRenderViewportElementBinder(
createRenderProtoView([createRenderComponentElementBinder(0)], ViewType.EMBEDDED))
]),
createRenderProtoView()
];
@ -391,7 +397,7 @@ export function main() {
}));
it('should cache compiled host components', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var mainPv = createProtoView();
var compiler = createCompiler([createRenderProtoView([])], [rootProtoView, mainPv]);
compiler.compileInHost(MainComponent)
@ -429,9 +435,9 @@ export function main() {
it('should cache compiled nested components', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent2, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(NestedComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
tplResolver.setView(MainComponent2, new ViewMetadata({template: '<div></div>'}));
tplResolver.setView(NestedComponent, new ViewMetadata({template: '<div></div>'}));
var rootProtoView2 = createRootProtoView(directiveResolver, MainComponent2);
var mainPv =
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]);
@ -459,9 +465,8 @@ export function main() {
}));
it('should re-use components being compiled', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
var renderProtoViewCompleter: PromiseCompleter<renderApi.ProtoViewDto> =
PromiseWrapper.completer();
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var renderProtoViewCompleter: PromiseCompleter<ProtoViewDto> = PromiseWrapper.completer();
var expectedProtoView = createProtoView();
var compiler = createCompiler([renderProtoViewCompleter.promise],
[rootProtoView, rootProtoView, expectedProtoView]);
@ -482,7 +487,7 @@ export function main() {
it('should throw on unconditional recursive components',
inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var mainProtoView =
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)]);
var compiler =
@ -498,15 +503,14 @@ export function main() {
it('should allow recursive components that are connected via an embedded ProtoView',
inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
var viewportProtoView =
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)],
renderApi.ViewType.EMBEDDED);
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var viewportProtoView = createProtoView(
[createComponentElementBinder(directiveResolver, MainComponent)], ViewType.EMBEDDED);
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
var renderPvDtos = [
createRenderProtoView([
createRenderViewportElementBinder(createRenderProtoView(
[createRenderComponentElementBinder(0)], renderApi.ViewType.EMBEDDED))
createRenderViewportElementBinder(
createRenderProtoView([createRenderComponentElementBinder(0)], ViewType.EMBEDDED))
]),
createRenderProtoView()
];
@ -530,15 +534,15 @@ export function main() {
it('should throw on recursive components that are connected via an embedded ProtoView with <ng-content>',
inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var viewportProtoView =
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)],
renderApi.ViewType.EMBEDDED, true);
ViewType.EMBEDDED, true);
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
var renderPvDtos = [
createRenderProtoView([
createRenderViewportElementBinder(createRenderProtoView(
[createRenderComponentElementBinder(0)], renderApi.ViewType.EMBEDDED))
createRenderViewportElementBinder(
createRenderProtoView([createRenderComponentElementBinder(0)], ViewType.EMBEDDED))
]),
createRenderProtoView()
];
@ -554,10 +558,9 @@ export function main() {
it('should create host proto views', inject([AsyncTestCompleter], (async) => {
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
var rootProtoView =
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)],
renderApi.ViewType.HOST);
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
var rootProtoView = createProtoView(
[createComponentElementBinder(directiveResolver, MainComponent)], ViewType.HOST);
var mainProtoView = createProtoView();
var compiler = createCompiler([createRenderProtoView()], [rootProtoView, mainProtoView]);
compiler.compileInHost(MainComponent)
@ -582,13 +585,13 @@ function createDirectiveBinding(directiveResolver, type): DirectiveBinding {
return DirectiveBinding.createFromType(type, annotation);
}
function createProtoView(elementBinders = null, type: renderApi.ViewType = null,
function createProtoView(elementBinders = null, type: ViewType = null,
isEmbeddedFragment: boolean = false): AppProtoView {
if (isBlank(type)) {
type = renderApi.ViewType.COMPONENT;
type = ViewType.COMPONENT;
}
var pv = new AppProtoView(type, isEmbeddedFragment, new renderApi.RenderProtoViewRef(), null,
null, new Map(), null, null);
var pv = new AppProtoView(type, isEmbeddedFragment, new RenderProtoViewRef(), null, null,
new Map(), null, null);
if (isBlank(elementBinders)) {
elementBinders = [];
}
@ -607,30 +610,28 @@ function createViewportElementBinder(nestedProtoView): ElementBinder {
return elBinder;
}
function createRenderProtoView(elementBinders = null, type: renderApi.ViewType = null):
renderApi.ProtoViewDto {
function createRenderProtoView(elementBinders = null, type: ViewType = null): ProtoViewDto {
if (isBlank(type)) {
type = renderApi.ViewType.COMPONENT;
type = ViewType.COMPONENT;
}
if (isBlank(elementBinders)) {
elementBinders = [];
}
return new renderApi.ProtoViewDto(
{elementBinders: elementBinders, type: type, render: new renderApi.RenderProtoViewRef()});
return new ProtoViewDto(
{elementBinders: elementBinders, type: type, render: new RenderProtoViewRef()});
}
function createRenderComponentElementBinder(directiveIndex): renderApi.ElementBinder {
return new renderApi.ElementBinder(
{directives: [new renderApi.DirectiveBinder({directiveIndex: directiveIndex})]});
function createRenderComponentElementBinder(directiveIndex): RenderElementBinder {
return new RenderElementBinder(
{directives: [new DirectiveBinder({directiveIndex: directiveIndex})]});
}
function createRenderViewportElementBinder(nestedProtoView): renderApi.ElementBinder {
return new renderApi.ElementBinder({nestedProtoView: nestedProtoView});
function createRenderViewportElementBinder(nestedProtoView): RenderElementBinder {
return new RenderElementBinder({nestedProtoView: nestedProtoView});
}
function createRootProtoView(directiveResolver, type): AppProtoView {
return createProtoView([createComponentElementBinder(directiveResolver, type)],
renderApi.ViewType.HOST);
return createProtoView([createComponentElementBinder(directiveResolver, type)], ViewType.HOST);
}
@Component({selector: 'main-comp'})
@ -699,16 +700,16 @@ class SpyDirectiveResolver extends SpyObject {
}
class FakeViewResolver extends ViewResolver {
_cmpViews: Map<Type, viewAnn.View> = new Map();
_cmpViews: Map<Type, ViewMetadata> = new Map();
constructor() { super(); }
resolve(component: Type): viewAnn.View {
resolve(component: Type): ViewMetadata {
// returns null for dynamic components
return this._cmpViews.has(component) ? this._cmpViews.get(component) : null;
}
setView(component: Type, view: viewAnn.View): void { this._cmpViews.set(component, view); }
setView(component: Type, view: ViewMetadata): void { this._cmpViews.set(component, view); }
}
class FakeProtoViewFactory extends ProtoViewFactory {
@ -719,15 +720,15 @@ class FakeProtoViewFactory extends ProtoViewFactory {
this.requests = [];
}
createAppProtoViews(componentBinding: DirectiveBinding, renderProtoView: renderApi.ProtoViewDto,
createAppProtoViews(componentBinding: DirectiveBinding, renderProtoView: ProtoViewDto,
directives: List<DirectiveBinding>, pipes: PipeBinding[]): AppProtoView[] {
this.requests.push([componentBinding, renderProtoView, directives, pipes]);
return collectEmbeddedPvs(ListWrapper.removeAt(this.results, 0));
}
}
class MergedRenderProtoViewRef extends renderApi.RenderProtoViewRef {
constructor(public originals: renderApi.RenderProtoViewRef[]) { super(); }
class MergedRenderProtoViewRef extends RenderProtoViewRef {
constructor(public originals: RenderProtoViewRef[]) { super(); }
}
function originalRenderProtoViewRefs(appProtoView: AppProtoView) {

View File

@ -13,7 +13,7 @@ import {
proxy
} from 'angular2/test_lib';
import {Directive, LifecycleEvent} from 'angular2/src/core/annotations_impl/annotations';
import {DirectiveMetadata, LifecycleEvent} from '../../../src/core/metadata';
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
export function main() {
@ -25,87 +25,99 @@ export function main() {
describe("onChange", () => {
it("should be true when the directive has the onChange method", () => {
expect(metadata(DirectiveWithOnChangeMethod, new Directive({})).callOnChange).toBe(true);
expect(metadata(DirectiveWithOnChangeMethod, new DirectiveMetadata({})).callOnChange)
.toBe(true);
});
it("should be true when the lifecycle includes onChange", () => {
expect(metadata(DirectiveNoHooks, new Directive({lifecycle: [LifecycleEvent.onChange]}))
expect(metadata(DirectiveNoHooks,
new DirectiveMetadata({lifecycle: [LifecycleEvent.onChange]}))
.callOnChange)
.toBe(true);
});
it("should be false otherwise",
() => { expect(metadata(DirectiveNoHooks, new Directive()).callOnChange).toBe(false); });
it("should be false otherwise", () => {
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnChange).toBe(false);
});
it("should be false when empty lifecycle", () => {
expect(metadata(DirectiveWithOnChangeMethod, new Directive({lifecycle: []})).callOnChange)
expect(metadata(DirectiveWithOnChangeMethod, new DirectiveMetadata({lifecycle: []}))
.callOnChange)
.toBe(false);
});
});
describe("onDestroy", () => {
it("should be true when the directive has the onDestroy method", () => {
expect(metadata(DirectiveWithOnDestroyMethod, new Directive({})).callOnDestroy)
expect(metadata(DirectiveWithOnDestroyMethod, new DirectiveMetadata({})).callOnDestroy)
.toBe(true);
});
it("should be true when the lifecycle includes onDestroy", () => {
expect(metadata(DirectiveNoHooks, new Directive({lifecycle: [LifecycleEvent.onDestroy]}))
expect(metadata(DirectiveNoHooks,
new DirectiveMetadata({lifecycle: [LifecycleEvent.onDestroy]}))
.callOnDestroy)
.toBe(true);
});
it("should be false otherwise", () => {
expect(metadata(DirectiveNoHooks, new Directive()).callOnDestroy).toBe(false);
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnDestroy).toBe(false);
});
});
describe("onInit", () => {
it("should be true when the directive has the onInit method", () => {
expect(metadata(DirectiveWithOnInitMethod, new Directive({})).callOnInit).toBe(true);
expect(metadata(DirectiveWithOnInitMethod, new DirectiveMetadata({})).callOnInit)
.toBe(true);
});
it("should be true when the lifecycle includes onDestroy", () => {
expect(metadata(DirectiveNoHooks, new Directive({lifecycle: [LifecycleEvent.onInit]}))
expect(metadata(DirectiveNoHooks,
new DirectiveMetadata({lifecycle: [LifecycleEvent.onInit]}))
.callOnInit)
.toBe(true);
});
it("should be false otherwise",
() => { expect(metadata(DirectiveNoHooks, new Directive()).callOnInit).toBe(false); });
it("should be false otherwise", () => {
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnInit).toBe(false);
});
});
describe("onCheck", () => {
it("should be true when the directive has the onCheck method", () => {
expect(metadata(DirectiveWithOnCheckMethod, new Directive({})).callOnCheck).toBe(true);
expect(metadata(DirectiveWithOnCheckMethod, new DirectiveMetadata({})).callOnCheck)
.toBe(true);
});
it("should be true when the lifecycle includes onCheck", () => {
expect(metadata(DirectiveNoHooks, new Directive({lifecycle: [LifecycleEvent.onCheck]}))
expect(metadata(DirectiveNoHooks,
new DirectiveMetadata({lifecycle: [LifecycleEvent.onCheck]}))
.callOnCheck)
.toBe(true);
});
it("should be false otherwise",
() => { expect(metadata(DirectiveNoHooks, new Directive()).callOnCheck).toBe(false); });
it("should be false otherwise", () => {
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnCheck).toBe(false);
});
});
describe("onAllChangesDone", () => {
it("should be true when the directive has the onAllChangesDone method", () => {
expect(
metadata(DirectiveWithOnAllChangesDoneMethod, new Directive({})).callOnAllChangesDone)
expect(metadata(DirectiveWithOnAllChangesDoneMethod, new DirectiveMetadata({}))
.callOnAllChangesDone)
.toBe(true);
});
it("should be true when the lifecycle includes onAllChangesDone", () => {
expect(metadata(DirectiveNoHooks,
new Directive({lifecycle: [LifecycleEvent.onAllChangesDone]}))
new DirectiveMetadata({lifecycle: [LifecycleEvent.onAllChangesDone]}))
.callOnAllChangesDone)
.toBe(true);
});
it("should be false otherwise", () => {
expect(metadata(DirectiveNoHooks, new Directive()).callOnAllChangesDone).toBe(false);
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnAllChangesDone)
.toBe(false);
});
});
});

View File

@ -1,7 +1,6 @@
import {ddescribe, describe, it, iit, expect, beforeEach} from 'angular2/test_lib';
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
import {Directive} from 'angular2/annotations';
import * as dirAnn from 'angular2/src/core/annotations_impl/annotations';
import {DirectiveMetadata, Directive} from 'angular2/metadata';
@Directive({selector: 'someDirective'})
class SomeDirective {
@ -21,7 +20,7 @@ export function main() {
it('should read out the Directive annotation', () => {
var directiveMetadata = reader.resolve(SomeDirective);
expect(directiveMetadata).toEqual(new dirAnn.Directive({selector: 'someDirective'}));
expect(directiveMetadata).toEqual(new Directive({selector: 'someDirective'}));
});
it('should throw if not matching annotation is found', () => {
@ -31,7 +30,7 @@ export function main() {
it('should not read parent class Directive annotations', function() {
var directiveMetadata = reader.resolve(SomeChildDirective);
expect(directiveMetadata).toEqual(new dirAnn.Directive({selector: 'someChildDirective'}));
expect(directiveMetadata).toEqual(new Directive({selector: 'someChildDirective'}));
});
});
}

View File

@ -20,8 +20,7 @@ import {
import {Injector} from 'angular2/di';
import {NgIf} from 'angular2/directives';
import {Component, View, LifecycleEvent} from 'angular2/annotations';
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
import {Component, View, ViewMetadata, LifecycleEvent} from 'angular2/metadata';
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
import {DOCUMENT} from 'angular2/src/render/render';
@ -35,7 +34,7 @@ export function main() {
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View(
new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
@ -53,7 +52,7 @@ export function main() {
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View(
new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
@ -70,13 +69,13 @@ export function main() {
it('should allow to dispose even if the location has been removed',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<child-cmp *ng-if="ctxBoolProp"></child-cmp>',
directives: [NgIf, ChildComp]
}))
.overrideView(
ChildComp,
new viewAnn.View(
new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
@ -103,7 +102,7 @@ export function main() {
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp, new viewAnn.View(
MyComp, new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
@ -125,7 +124,7 @@ export function main() {
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View(
new ViewMetadata(
{template: '<location #loc></location>', directives: [Location]}))
.createAsync(MyComp)
.then((tc) => {
@ -140,7 +139,8 @@ export function main() {
describe("loading next to a location", () => {
it('should work', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template: '<div><location #loc></location></div>',
directives: [Location]
}))
@ -160,7 +160,7 @@ export function main() {
it('should return a disposable component ref',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div><location #loc></location></div>',
directives: [Location]
}))
@ -193,7 +193,7 @@ export function main() {
it('should update host properties',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader, tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div><location #loc></location></div>',
directives: [Location]
}))

View File

@ -32,14 +32,13 @@ import {
DirectiveBinding,
TreeNode
} from 'angular2/src/core/compiler/element_injector';
import * as dirAnn from 'angular2/src/core/annotations_impl/annotations';
import {
Attribute,
Query,
Component,
Directive,
ComponentMetadata,
DirectiveMetadata,
LifecycleEvent
} from 'angular2/annotations';
} from 'angular2/metadata';
import {bind, Injector, Binding, Optional, Inject, Injectable, Self, SkipSelf, InjectMetadata, Host, HostMetadata, SkipSelfMetadata} from 'angular2/di';
import {AppProtoView, AppView} from 'angular2/src/core/compiler/view';
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
@ -420,7 +419,7 @@ export function main() {
describe('event emitters', () => {
it('should return a list of event accessors', () => {
var binding = DirectiveBinding.createFromType(HasEventEmitter,
new dirAnn.Directive({events: ['emitter']}));
new DirectiveMetadata({events: ['emitter']}));
var inj = createPei(null, 0, [binding]);
expect(inj.eventEmitterAccessors.length).toEqual(1);
@ -432,7 +431,7 @@ export function main() {
it('should allow a different event vs field name', () => {
var binding = DirectiveBinding.createFromType(HasEventEmitter,
new dirAnn.Directive({events: ['emitter: publicEmitter']}));
new DirectiveMetadata({events: ['emitter: publicEmitter']}));
var inj = createPei(null, 0, [binding]);
expect(inj.eventEmitterAccessors.length).toEqual(1);
@ -444,7 +443,7 @@ export function main() {
it('should return a list of hostAction accessors', () => {
var binding = DirectiveBinding.createFromType(
HasEventEmitter, new dirAnn.Directive({host: {'@hostActionName': 'onAction'}}));
HasEventEmitter, new DirectiveMetadata({host: {'@hostActionName': 'onAction'}}));
var inj = createPei(null, 0, [binding]);
expect(inj.hostActionAccessors.length).toEqual(1);
@ -460,8 +459,8 @@ export function main() {
var pei = createPei(null, 0, [
DirectiveBinding.createFromType(
SimpleDirective,
new dirAnn.Component({bindings: [bind('injectable1').toValue('injectable1')]})),
DirectiveBinding.createFromType(SomeOtherDirective, new dirAnn.Component({
new ComponentMetadata({bindings: [bind('injectable1').toValue('injectable1')]})),
DirectiveBinding.createFromType(SomeOtherDirective, new ComponentMetadata({
bindings: [bind('injectable2').toValue('injectable2')]
}))
]);
@ -474,7 +473,7 @@ export function main() {
it("should collect view bindings from the component", () => {
var pei = createPei(null, 0,
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
[DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
viewBindings: [bind('injectable1').toValue('injectable1')]
}))],
0, true);
@ -487,7 +486,7 @@ export function main() {
var pei = createPei(null, 0, [
DirectiveBinding.createFromType(
SimpleDirective,
new dirAnn.Component({
new ComponentMetadata({
viewBindings: [[[bind('view').toValue('view')]]],
bindings: [[[bind('host').toValue('host')]]]
}))
@ -595,11 +594,11 @@ export function main() {
function() {
var childInj = parentChildInjectors(
ListWrapper.concat(
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
[DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
bindings: [bind('injectable1').toValue('injectable1')]
}))],
extraBindings),
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
[DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
bindings: [
bind('injectable1')
.toValue('new-injectable1'),
@ -624,7 +623,7 @@ export function main() {
var inj = injector(ListWrapper.concat(
[DirectiveBinding.createFromType(SimpleDirective,
new dirAnn.Directive({bindings: bindings}))],
new DirectiveMetadata({bindings: bindings}))],
extraBindings));
expect(inj.get('injectable2')).toEqual('injectable1-injectable2');
@ -642,7 +641,7 @@ export function main() {
var inj = injector(ListWrapper.concat(
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
[DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
viewBindings: viewBindings}))], extraBindings),
null, true);
expect(inj.get('injectable2')).toEqual('injectable1-injectable2');
@ -650,7 +649,7 @@ export function main() {
it("should instantiate components that depend on viewBindings bindings", () => {
var inj = injector(
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new dirAnn.Component({
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new ComponentMetadata({
viewBindings: [bind('service').toValue('service')]
}))],
extraBindings),
@ -661,7 +660,7 @@ export function main() {
it("should instantiate bindings lazily", () => {
var created = false;
var inj = injector(
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
bindings: [bind('service').toFactory(() => created = true)]
}))],
extraBindings),
@ -677,7 +676,7 @@ export function main() {
it("should instantiate view bindings lazily", () => {
var created = false;
var inj = injector(
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
viewBindings: [bind('service').toFactory(() => created = true)]
}))],
extraBindings),
@ -692,7 +691,7 @@ export function main() {
it("should not instantiate other directives that depend on viewBindings bindings",
() => {
var directiveAnnotation = new dirAnn.Component({
var directiveAnnotation = new ComponentMetadata({
viewBindings: ListWrapper.concat([bind("service").toValue("service")], extraBindings)
});
var componentDirective =
@ -704,7 +703,7 @@ export function main() {
it("should instantiate directives that depend on bindings bindings of other directives", () => {
var shadowInj = hostShadowInjectors(
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
bindings: [bind('service').toValue('hostService')]})
)], extraBindings),
ListWrapper.concat([NeedsService], extraBindings)
@ -742,7 +741,7 @@ export function main() {
it("should prioritize viewBindings over bindings for the same binding", () => {
var inj = injector(
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new dirAnn.Component({
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new ComponentMetadata({
bindings: [bind('service').toValue('hostService')],
viewBindings: [bind('service').toValue('viewService')]})
)], extraBindings), null, true);
@ -755,7 +754,7 @@ export function main() {
hostShadowInjectors(
ListWrapper.concat([
SimpleDirective,
DirectiveBinding.createFromType(SomeOtherDirective, new dirAnn.Directive({
DirectiveBinding.createFromType(SomeOtherDirective, new DirectiveMetadata({
bindings: [bind('service').toValue('hostService')]})
)], extraBindings),
@ -827,7 +826,7 @@ export function main() {
it("should instantiate directives that depend on the containing component", () => {
var directiveBinding =
DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component());
DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata());
var shadow = hostShadowInjectors(ListWrapper.concat([directiveBinding], extraBindings),
[NeeedsDirectiveFromHost]);
@ -839,7 +838,7 @@ export function main() {
it("should not instantiate directives that depend on other directives in the containing component's ElementInjector",
() => {
var directiveBinding =
DirectiveBinding.createFromType(SomeOtherDirective, new dirAnn.Component());
DirectiveBinding.createFromType(SomeOtherDirective, new ComponentMetadata());
expect(() =>
{
hostShadowInjectors(
@ -855,7 +854,7 @@ export function main() {
it("should call onDestroy on directives subscribed to this event", () => {
var inj = injector(ListWrapper.concat(
[DirectiveBinding.createFromType(DirectiveWithDestroy,
new dirAnn.Directive({lifecycle: [LifecycleEvent.onDestroy]}))],
new DirectiveMetadata({lifecycle: [LifecycleEvent.onDestroy]}))],
extraBindings));
var destroy = inj.get(DirectiveWithDestroy);
inj.dehydrate();
@ -865,7 +864,7 @@ export function main() {
it("should work with services", () => {
var inj = injector(ListWrapper.concat(
[DirectiveBinding.createFromType(
SimpleDirective, new dirAnn.Directive({bindings: [SimpleService]}))],
SimpleDirective, new DirectiveMetadata({bindings: [SimpleService]}))],
extraBindings));
inj.dehydrate();
});
@ -942,7 +941,7 @@ export function main() {
var childView = new DummyView();
childView.changeDetector = cd;
view.spy('getNestedView').andReturn(childView);
var binding = DirectiveBinding.createFromType(ComponentNeedsChangeDetectorRef, new dirAnn.Component());
var binding = DirectiveBinding.createFromType(ComponentNeedsChangeDetectorRef, new ComponentMetadata());
var inj = injector(ListWrapper.concat([binding], extraBindings), null, true,
new PreBuiltObjects(null, view, <any>new DummyElementRef(), null));
@ -953,7 +952,7 @@ export function main() {
var cd = new DynamicChangeDetector(null, null, null, [], [], []);
var view = <any>new DummyView();
view.changeDetector =cd;
var binding = DirectiveBinding.createFromType(DirectiveNeedsChangeDetectorRef, new dirAnn.Directive());
var binding = DirectiveBinding.createFromType(DirectiveNeedsChangeDetectorRef, new DirectiveMetadata());
var inj = injector(ListWrapper.concat([binding], extraBindings), null, false,
new PreBuiltObjects(null, view, <any>new DummyElementRef(), null));

View File

@ -61,8 +61,7 @@ import {
ON_PUSH
} from 'angular2/src/change_detection/change_detection';
import {Directive, Component, View, Attribute, Query, Pipe} from 'angular2/annotations';
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
import {Directive, Component, View, ViewMetadata, Attribute, Query, Pipe} from 'angular2/metadata';
import {QueryList} from 'angular2/src/core/compiler/query_list';
@ -89,7 +88,7 @@ export function main() {
describe('react to record changes', function() {
it('should consume text node changes',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({template: '<div>{{ctxProp}}</div>'}))
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{ctxProp}}</div>'}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Hello World!';
@ -103,7 +102,7 @@ export function main() {
it('should update text node with a blank string when interpolation evaluates to null',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({template: '<div>{{null}}{{ctxProp}}</div>'}))
tcb.overrideView(MyComp, new ViewMetadata({template: '<div>{{null}}{{ctxProp}}</div>'}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = null;
@ -116,7 +115,7 @@ export function main() {
it('should consume element binding changes',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({template: '<div [id]="ctxProp"></div>'}))
tcb.overrideView(MyComp, new ViewMetadata({template: '<div [id]="ctxProp"></div>'}))
.createAsync(MyComp)
.then((rootTC) => {
@ -131,7 +130,7 @@ export function main() {
it('should consume binding to aria-* attributes',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp,
new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'}))
new ViewMetadata({template: '<div [attr.aria-label]="ctxProp"></div>'}))
.createAsync(MyComp)
.then((rootTC) => {
@ -155,7 +154,7 @@ export function main() {
it('should consume binding to property names where attr name and property name do not match',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp,
new viewAnn.View({template: '<div [tabindex]="ctxNumProp"></div>'}))
new ViewMetadata({template: '<div [tabindex]="ctxNumProp"></div>'}))
.createAsync(MyComp)
.then((rootTC) => {
@ -174,7 +173,7 @@ export function main() {
it('should consume binding to camel-cased properties using dash-cased syntax in templates',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp,
new viewAnn.View({template: '<input [read-only]="ctxBoolProp">'}))
new ViewMetadata({template: '<input [read-only]="ctxBoolProp">'}))
.createAsync(MyComp)
.then((rootTC) => {
@ -193,7 +192,7 @@ export function main() {
it('should consume binding to inner-html',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp,
new viewAnn.View({template: '<div inner-html="{{ctxProp}}"></div>'}))
new ViewMetadata({template: '<div inner-html="{{ctxProp}}"></div>'}))
.createAsync(MyComp)
.then((rootTC) => {
@ -216,7 +215,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View({template: '<div class="initial" [class]="ctxProp"></div>'}))
new ViewMetadata({template: '<div class="initial" [class]="ctxProp"></div>'}))
.createAsync(MyComp)
.then((rootTC) => {
@ -240,7 +239,7 @@ export function main() {
'<div my-dir elprop="Hi {{\'there!\'}}"></div>' +
'<div my-dir elprop="One more {{ctxProp}}"></div>' +
'</div>';
tcb.overrideView(MyComp, new viewAnn.View({template: tpl, directives: [MyDir]}))
tcb.overrideView(MyComp, new ViewMetadata({template: tpl, directives: [MyDir]}))
.createAsync(MyComp)
.then((rootTC) => {
@ -260,9 +259,10 @@ export function main() {
describe('pipes', () => {
it("should support pipes in bindings",
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
inject(
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp, new ViewMetadata({
template: '<div my-dir #dir="mydir" [elprop]="ctxProp | double"></div>',
directives: [MyDir],
pipes: [DoublePipe]
@ -284,7 +284,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View({template: '<child-cmp></child-cmp>', directives: [ChildComp]}))
new ViewMetadata({template: '<child-cmp></child-cmp>', directives: [ChildComp]}))
.createAsync(MyComp)
.then((rootTC) => {
@ -299,7 +299,7 @@ export function main() {
// GH issue 328 - https://github.com/angular/angular/issues/328
it('should support different directive types on a single node',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>',
directives: [MyDir, ChildComp]
}))
@ -321,7 +321,7 @@ export function main() {
it('should support directives where a binding attribute is not given',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
// No attribute "el-prop" specified.
template: '<p my-dir></p>',
directives: [MyDir]
@ -333,7 +333,8 @@ export function main() {
it('should execute a given directive once, even if specified multiple times',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template: '<p no-duplicate></p>',
directives: [
DuplicateDir,
@ -350,7 +351,7 @@ export function main() {
it('should use the last directive binding per directive',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<p no-duplicate></p>',
directives: [
bind(DuplicateDir)
@ -367,7 +368,7 @@ export function main() {
it('should support directives where a selector matches property binding',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View(
tcb.overrideView(MyComp, new ViewMetadata(
{template: '<p [id]="ctxProp"></p>', directives: [IdDir]}))
.createAsync(MyComp)
@ -389,7 +390,7 @@ export function main() {
it('should allow specifying directives as bindings',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<child-cmp></child-cmp>',
directives: [bind(ChildComp).toClass(ChildComp)]
}))
@ -405,7 +406,7 @@ export function main() {
it('should read directives metadata from their binding token',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div public-api><div needs-public-api></div></div>',
directives: [bind(PublicApi).toClass(PrivateImpl), NeedsPublicApi]
}))
@ -416,7 +417,8 @@ export function main() {
it('should support template directives via `<template>` elements.',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template:
'<div><template some-viewport var-greeting="some-tmpl"><copy-me>{{greeting}}</copy-me></template></div>',
directives: [SomeViewport]
@ -438,7 +440,8 @@ export function main() {
it('should support template directives via `template` attribute.',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template:
'<div><copy-me template="some-viewport: var greeting=some-tmpl">{{greeting}}</copy-me></div>',
directives: [SomeViewport]
@ -459,7 +462,8 @@ export function main() {
it('should allow to transplant embedded ProtoViews into other ViewContainers',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template:
'<some-directive><toolbar><template toolbarpart var-toolbar-prop="toolbarProp">{{ctxProp}},{{toolbarProp}},<cmp-with-host></cmp-with-host></template></toolbar></some-directive>',
directives: [SomeDirective, CompWithHost, ToolbarComponent, ToolbarPart]
@ -480,8 +484,8 @@ export function main() {
describe("variable bindings", () => {
it('should assign a component to a var-',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder,
async) => {tcb.overrideView(MyComp, new viewAnn.View({
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<p><child-cmp var-alice></child-cmp></p>',
directives: [ChildComp]
}))
@ -497,7 +501,7 @@ export function main() {
it('should assign a directive to a var-',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<p><div export-dir #localdir="dir"></div></p>',
directives: [ExportDir]
}))
@ -512,9 +516,11 @@ export function main() {
}));
it('should make the assigned component accessible in property bindings',
inject([TestComponentBuilder, AsyncTestCompleter],
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template: '<p><child-cmp var-alice></child-cmp>{{alice.ctxProp}}</p>',
directives: [ChildComp]
}))
@ -531,9 +537,11 @@ export function main() {
})}));
it('should assign two component instances each with a var-',
inject([TestComponentBuilder, AsyncTestCompleter],
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template: '<p><child-cmp var-alice></child-cmp><child-cmp var-bob></p>',
directives: [ChildComp]
}))
@ -554,7 +562,7 @@ export function main() {
it('should assign the component instance to a var- with shorthand syntax',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder,
async) => {tcb.overrideView(MyComp, new viewAnn.View({
async) => {tcb.overrideView(MyComp, new ViewMetadata({
template: '<child-cmp #alice></child-cmp>',
directives: [ChildComp]
}))
@ -572,7 +580,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp,
new viewAnn.View(
new ViewMetadata(
{template: '<p><div var-alice><i>Hello</i></div></p>'}))
.createAsync(MyComp)
@ -588,7 +596,7 @@ export function main() {
it('should change dash-case to camel-case',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<p><child-cmp var-super-alice></child-cmp></p>',
directives: [ChildComp]
}))
@ -605,7 +613,8 @@ export function main() {
it('should allow to use variables in a for loop',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template:
'<div><div *ng-for="var i of [1]"><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</div></div>',
directives: [ChildCompNoTemplate, NgFor]
@ -628,7 +637,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>',
directives: [[[PushCmpWithRef]]]
}))
@ -655,7 +664,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
directives: [[[PushCmp]]]
}))
@ -676,11 +685,12 @@ export function main() {
})}));
it('should not affect updating properties on the component',
inject(
[TestComponentBuilder, AsyncTestCompleter],
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
template: '<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
tcb.overrideView(
MyComp, new ViewMetadata({
template:
'<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
directives: [[[PushCmpWithRef]]]
}))
@ -703,7 +713,8 @@ export function main() {
if (DOM.supportsDOMEvents()) {
it('should be checked when an async pipe requests a check',
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
tcb = tcb.overrideView(MyComp, new viewAnn.View({
tcb = tcb.overrideView(
MyComp, new ViewMetadata({
template: '<push-cmp-with-async #cmp></push-cmp-with-async>',
directives: [[[PushCmpWithAsyncPipe]]]
}));
@ -732,7 +743,7 @@ export function main() {
it('should create a component that injects an @Host',
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: `
<some-directive>
<p>
@ -753,7 +764,7 @@ export function main() {
it('should create a component that injects an @Host through viewcontainer directive',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: `
<some-directive>
<p *ng-if="true">
@ -778,7 +789,7 @@ export function main() {
it('should support events via EventEmitter',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div emitter listener></div>',
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
}))
@ -803,7 +814,7 @@ export function main() {
it('should support [()] syntax',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div [(control)]="ctxProp" two-way></div>',
directives: [DirectiveWithTwoWayBinding]
}))
@ -831,7 +842,7 @@ export function main() {
it("should support invoking methods on the host element via hostActions",
inject(
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div update-host-actions></div>',
directives: [DirectiveUpdatingHostActions]
}))
@ -856,7 +867,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View(
new ViewMetadata(
{template: '<div listener></div>', directives: [DirectiveListeningDomEvent]}))
.createAsync(MyComp)
@ -877,7 +888,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View(
new ViewMetadata(
{template: '<div listener></div>', directives: [DirectiveListeningDomEvent]}))
.createAsync(MyComp)
@ -902,7 +913,7 @@ export function main() {
it('should support updating host element via hostAttributes',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div update-host-attributes></div>',
directives: [DirectiveUpdatingHostAttributes]
}))
@ -920,7 +931,7 @@ export function main() {
it('should support updating host element via hostProperties',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div update-host-properties></div>',
directives: [DirectiveUpdatingHostProperties]
}))
@ -945,11 +956,14 @@ export function main() {
it('should support preventing default on render events',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template:
'<input type="checkbox" listenerprevent></input><input type="checkbox" listenernoprevent></input>',
directives:
[DirectiveListeningDomEventPrevent, DirectiveListeningDomEventNoPrevent]
directives: [
DirectiveListeningDomEventPrevent,
DirectiveListeningDomEventNoPrevent
]
}))
.createAsync(MyComp)
@ -973,9 +987,11 @@ export function main() {
it('should support render global events from multiple directives',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template: '<div *ng-if="ctxBoolProp" listener listenerother></div>',
directives: [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
directives:
[NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
}))
.createAsync(MyComp)
@ -1013,7 +1029,7 @@ export function main() {
it('should allow to create a ViewContainerRef at any bound location',
inject([TestComponentBuilder, AsyncTestCompleter, Compiler],
(tcb: TestComponentBuilder, async, compiler) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',
directives: [DynamicViewport]
}))
@ -1037,7 +1053,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View(
new ViewMetadata(
{template: '<input static type="text" title>', directives: [NeedsAttribute]}))
.createAsync(MyComp)
.then((rootTC) => {
@ -1055,7 +1071,8 @@ export function main() {
describe("dependency injection", () => {
it("should support bindings",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template: `
<directive-providing-injectable >
<directive-consuming-injectable #consuming>
@ -1075,7 +1092,7 @@ export function main() {
it("should support viewBindings",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(DirectiveProvidingInjectableInView, new viewAnn.View({
tcb.overrideView(DirectiveProvidingInjectableInView, new ViewMetadata({
template: `
<directive-consuming-injectable #consuming>
</directive-consuming-injectable>
@ -1093,7 +1110,7 @@ export function main() {
it("should support unbounded lookup",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: `
<directive-providing-injectable>
<directive-containing-directive-consuming-an-injectable #dir>
@ -1105,7 +1122,7 @@ export function main() {
DirectiveContainingDirectiveConsumingAnInjectable
]
}))
.overrideView(DirectiveContainingDirectiveConsumingAnInjectable, new viewAnn.View({
.overrideView(DirectiveContainingDirectiveConsumingAnInjectable, new ViewMetadata({
template: `
<directive-consuming-injectable-unbounded></directive-consuming-injectable-unbounded>
`,
@ -1123,7 +1140,7 @@ export function main() {
it("should support the event-bus scenario",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: `
<grand-parent-providing-event-bus>
<parent-providing-event-bus>
@ -1159,7 +1176,8 @@ export function main() {
it("should instantiate bindings lazily",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(
MyComp, new ViewMetadata({
template: `
<component-providing-logging-injectable #providing>
<directive-consuming-injectable *ng-if="ctxBoolProp">
@ -1187,7 +1205,7 @@ export function main() {
describe("corner cases", () => {
it('should remove script tags from templates',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: `
<script>alert("Ooops");</script>
<div>before<script>alert("Ooops");</script><span>inside</span>after</div>`
@ -1204,7 +1222,7 @@ export function main() {
it('should report a meaningful error when a directive is missing annotation',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb = tcb.overrideView(MyComp,
new viewAnn.View({directives: [SomeDirectiveMissingAnnotation]}));
new ViewMetadata({directives: [SomeDirectiveMissingAnnotation]}));
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
expect(e.message).toEqual(
@ -1227,7 +1245,7 @@ export function main() {
it('should report a meaningful error when a directive is null',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb = tcb.overrideView(MyComp, new viewAnn.View({directives: [[null]]}));
tcb = tcb.overrideView(MyComp, new ViewMetadata({directives: [[null]]}));
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
expect(e.message).toEqual(
@ -1240,7 +1258,8 @@ export function main() {
it('should provide an error context when an error happens in DI',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb = tcb.overrideView(MyComp, new viewAnn.View({
tcb =
tcb.overrideView(MyComp, new ViewMetadata({
directives: [DirectiveThrowingAnError],
template: `<directive-throwing-error></<directive-throwing-error>`
}));
@ -1259,7 +1278,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb = tcb.overrideView(
MyComp, new viewAnn.View({template: `<input [value]="one.two.three" #local>`}));
MyComp, new ViewMetadata({template: `<input [value]="one.two.three" #local>`}));
tcb.createAsync(MyComp).then(rootTC => {
try {
@ -1282,7 +1301,7 @@ export function main() {
it('should provide an error context when an error happens in change detection (text node)',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb = tcb.overrideView(MyComp, new viewAnn.View({template: `{{one.two.three}}`}));
tcb = tcb.overrideView(MyComp, new ViewMetadata({template: `{{one.two.three}}`}));
tcb.createAsync(MyComp).then(rootTC => {
try {
@ -1302,7 +1321,8 @@ export function main() {
it('should provide an error context when an error happens in an event handler',
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
tcb = tcb.overrideView(MyComp, new viewAnn.View({
tcb = tcb.overrideView(
MyComp, new ViewMetadata({
template: `<span emitter listener (event)="throwError()" #local></span>`,
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
}));
@ -1337,7 +1357,7 @@ export function main() {
var undefinedValue;
tcb = tcb.overrideView(MyComp, new viewAnn.View({directives: [undefinedValue]}));
tcb = tcb.overrideView(MyComp, new ViewMetadata({directives: [undefinedValue]}));
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
expect(e.message).toEqual(
@ -1352,7 +1372,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({template: '{{a.b}}'}))
tcb.overrideView(MyComp, new ViewMetadata({template: '{{a.b}}'}))
.createAsync(MyComp)
.then((rootTC) => {
@ -1366,7 +1386,7 @@ export function main() {
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({template: '<div [title]="a.b"></div>'}))
tcb.overrideView(MyComp, new ViewMetadata({template: '<div [title]="a.b"></div>'}))
.createAsync(MyComp)
.then((rootTC) => {
@ -1379,7 +1399,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<child-cmp [title]="a.b"></child-cmp>',
directives: [ChildComp]
}))
@ -1394,7 +1414,7 @@ export function main() {
it('should support imperative views',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<simple-imp-cmp></simple-imp-cmp>',
directives: [SimpleImperativeViewComponent]
}))
@ -1406,9 +1426,9 @@ export function main() {
}));
it('should support moving embedded views around',
inject([TestComponentBuilder, AsyncTestCompleter, ANCHOR_ELEMENT],
(tcb, async, anchorElement) => {
tcb.overrideView(MyComp, new viewAnn.View({
inject([TestComponentBuilder, AsyncTestCompleter, ANCHOR_ELEMENT], (tcb, async,
anchorElement) => {
tcb.overrideView(MyComp, new ViewMetadata({
template: '<div><div *some-impvp="ctxBoolProp">hello</div></div>',
directives: [SomeImperativeViewport]
}))
@ -1437,7 +1457,7 @@ export function main() {
async) => {
tcb =
tcb.overrideView(MyComp,
new viewAnn.View({template: '<div unknown="{{ctxProp}}"></div>'}))
new ViewMetadata({template: '<div unknown="{{ctxProp}}"></div>'}))
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
expect(e.message).toEqual(
@ -1452,7 +1472,7 @@ export function main() {
async) => {
tcb.overrideView(
MyComp,
new viewAnn.View(
new ViewMetadata(
{template: '<div my-dir [elprop]="ctxProp"></div>', directives: [MyDir]}))
.createAsync(MyComp)
.then((val) => { async.done(); });
@ -1461,7 +1481,7 @@ export function main() {
it('should not be created when there is a directive with the same property',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<span [title]="ctxProp"></span>',
directives: [DirectiveWithTitle]
}))
@ -1480,7 +1500,7 @@ export function main() {
it('should work when a directive uses hostProperty to update the DOM element',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({
tcb.overrideView(MyComp, new ViewMetadata({
template: '<span [title]="ctxProp"></span>',
directives: [DirectiveWithTitleAndHostProperty]
}))
@ -1504,7 +1524,7 @@ export function main() {
return inject(
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp,
new viewAnn.View({template: `<!--${mode}--><div>{{ctxProp}}</div>`}))
new ViewMetadata({template: `<!--${mode}--><div>{{ctxProp}}</div>`}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = 'Hello World!';
@ -1526,7 +1546,7 @@ export function main() {
// - https://github.com/angular/angular/commit/81f3f32
xdescribe('Missing directive checks', () => {
function expectCompileError(tcb, inlineTpl, errMessage, done) {
tcb = tcb.overrideView(MyComp, new viewAnn.View({template: inlineTpl}));
tcb = tcb.overrideView(MyComp, new ViewMetadata({template: inlineTpl}));
PromiseWrapper.then(
tcb.createAsync(MyComp),
(value) => {

View File

@ -23,8 +23,6 @@ import {
import {DOM} from 'angular2/src/dom/dom_adapter';
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
import {
Component,
Directive,
@ -43,7 +41,7 @@ export function main() {
describe('projection', () => {
it('should support simple components',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<simple>' +
'<div>A</div>' +
'</simple>',
@ -58,7 +56,7 @@ export function main() {
it('should support simple components with text interpolation as direct children',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '{{\'START(\'}}<simple>' +
'{{text}}' +
'</simple>{{\')END\'}}',
@ -78,11 +76,10 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
Simple,
new viewAnn.View(
new View(
{template: 'SIMPLE(<div><ng-content></ng-content></div>)', directives: []}))
.overrideView(
MainComp,
new viewAnn.View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
.overrideView(MainComp,
new View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
.createAsync(MainComp)
.then((main) => {
@ -96,13 +93,14 @@ export function main() {
it('should support projecting text interpolation to a non bound element with other bound elements after it',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(Simple, new viewAnn.View({
template: 'SIMPLE(<div><ng-content></ng-content></div><div [tab-index]="0">EL</div>)',
tcb.overrideView(
Simple, new View({
template:
'SIMPLE(<div><ng-content></ng-content></div><div [tab-index]="0">EL</div>)',
directives: []
}))
.overrideView(
MainComp,
new viewAnn.View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
.overrideView(MainComp,
new View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
.createAsync(MainComp)
.then((main) => {
@ -115,8 +113,7 @@ export function main() {
it('should not show the light dom even if there is no content tag',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp,
new viewAnn.View({template: '<empty>A</empty>', directives: [Empty]}))
tcb.overrideView(MainComp, new View({template: '<empty>A</empty>', directives: [Empty]}))
.createAsync(MainComp)
.then((main) => {
@ -127,7 +124,7 @@ export function main() {
it('should support multiple content tags',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<multiple-content-tags>' +
'<div>B</div>' +
'<div>C</div>' +
@ -145,7 +142,7 @@ export function main() {
it('should redistribute only direct children',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<multiple-content-tags>' +
'<div>B<div class="left">A</div></div>' +
'<div>C</div>' +
@ -162,7 +159,7 @@ export function main() {
it("should redistribute direct child viewcontainers when the light dom changes",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<multiple-content-tags>' +
'<template manual class="left"><div>A1</div></template>' +
'<div>B</div>' +
@ -188,7 +185,7 @@ export function main() {
it("should support nested components",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<outer-with-indirect-nested>' +
'<div>A</div>' +
'<div>B</div>' +
@ -205,7 +202,7 @@ export function main() {
it("should support nesting with content being direct child of a nested component",
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<outer>' +
'<template manual class="left"><div>A</div></template>' +
'<div>B</div>' +
@ -229,7 +226,7 @@ export function main() {
it('should redistribute when the shadow dom changes',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<conditional-content>' +
'<div class="left">A</div>' +
'<div>B</div>' +
@ -263,8 +260,7 @@ export function main() {
tcb.overrideView(
MainComp,
new viewAnn.View(
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
new View({template: '<simple string-prop="text"></simple>', directives: [Simple]}))
.overrideTemplate(Simple, '<ng-content></ng-content><p>P,</p>{{stringProp}}')
.createAsync(MainComp)
.then((main) => {
@ -284,8 +280,7 @@ export function main() {
tcb.overrideView(
MainComp,
new viewAnn.View(
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
new View({template: '<simple string-prop="text"></simple>', directives: [Simple]}))
.overrideTemplate(Simple, '<style></style><p>P,</p>{{stringProp}}')
.createAsync(MainComp)
.then((main) => {
@ -298,7 +293,7 @@ export function main() {
it('should support moving non projected light dom around',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<empty>' +
' <template manual><div>A</div></template>' +
'</empty>' +
@ -323,7 +318,7 @@ export function main() {
it('should support moving projected light dom around',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<simple><template manual><div>A</div></template></simple>' +
'START(<div project></div>)END',
directives: [Simple, ProjectDirective, ManualViewportDirective],
@ -346,7 +341,8 @@ export function main() {
it('should support moving ng-content around',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(
MainComp, new View({
template: '<conditional-content>' +
'<div class="left">A</div>' +
'<div>B</div>' +
@ -382,8 +378,7 @@ export function main() {
// the presence of ng-content elements!
it('should still allow to implement a recursive trees',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp,
new viewAnn.View({template: '<tree></tree>', directives: [Tree]}))
tcb.overrideView(MainComp, new View({template: '<tree></tree>', directives: [Tree]}))
.createAsync(MainComp)
.then((main) => {
@ -402,7 +397,7 @@ export function main() {
if (DOM.supportsNativeShadowDOM()) {
it('should support native content projection',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: '<simple-native>' +
'<div>A</div>' +
'</simple-native>',
@ -422,7 +417,7 @@ export function main() {
it('should support nested conditionals that contain ng-contents',
inject(
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MainComp, new viewAnn.View({
tcb.overrideView(MainComp, new View({
template: `<conditional-text>a</conditional-text>`,
directives: [ConditionalTextComponent]
}))

View File

@ -29,11 +29,18 @@ import {
createDirectiveVariableBindings,
createVariableLocations
} from 'angular2/src/core/compiler/proto_view_factory';
import {Component, Directive} from 'angular2/annotations';
import {Component, Directive} from 'angular2/metadata';
import {Key} from 'angular2/di';
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
import * as renderApi from 'angular2/src/render/api';
import {
RenderElementBinder,
EventBinding,
RenderDirectiveMetadata,
ViewType,
ProtoViewDto,
DirectiveBinder
} from 'angular2/src/render/api';
export function main() {
// TODO(tbosch): add missing tests
@ -81,15 +88,15 @@ export function main() {
describe("createDirectiveVariableBindings", () => {
it("should calculate directive variable bindings", () => {
var dvbs = createDirectiveVariableBindings(
new renderApi.ElementBinder({
new RenderElementBinder({
variableBindings:
MapWrapper.createFromStringMap<string>({"exportName": "templateName"})
}),
[
directiveBinding(
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}),
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})}),
directiveBinding(
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'otherName'})})
{metadata: RenderDirectiveMetadata.create({exportAs: 'otherName'})})
]);
expect(dvbs).toEqual(MapWrapper.createFromStringMap<number>({"templateName": 0}));
@ -97,14 +104,14 @@ export function main() {
it("should set exportAs to $implicit for component with exportAs = null", () => {
var dvbs = createDirectiveVariableBindings(
new renderApi.ElementBinder({
new RenderElementBinder({
variableBindings:
MapWrapper.createFromStringMap<string>({"$implicit": "templateName"})
}),
[
directiveBinding({
metadata: renderApi.DirectiveMetadata.create(
{exportAs: null, type: renderApi.DirectiveMetadata.COMPONENT_TYPE})
metadata: RenderDirectiveMetadata.create(
{exportAs: null, type: RenderDirectiveMetadata.COMPONENT_TYPE})
})
]);
@ -114,13 +121,13 @@ export function main() {
it("should throw we no directive exported with this name", () => {
expect(() => {
createDirectiveVariableBindings(
new renderApi.ElementBinder({
new RenderElementBinder({
variableBindings:
MapWrapper.createFromStringMap<string>({"someInvalidName": "templateName"})
}),
[
directiveBinding(
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})})
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})})
]);
}).toThrowError(new RegExp("Cannot find directive with exportAs = 'someInvalidName'"));
});
@ -128,27 +135,25 @@ export function main() {
it("should throw when binding to a name exported by two directives", () => {
expect(() => {
createDirectiveVariableBindings(
new renderApi.ElementBinder({
new RenderElementBinder({
variableBindings:
MapWrapper.createFromStringMap<string>({"exportName": "templateName"})
}),
[
directiveBinding(
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}),
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})}),
directiveBinding(
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})})
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})})
]);
}).toThrowError(new RegExp("More than one directive have exportAs = 'exportName'"));
});
it("should not throw when not binding to a name exported by two directives", () => {
expect(() => {
createDirectiveVariableBindings(
new renderApi.ElementBinder({variableBindings: new Map()}), [
createDirectiveVariableBindings(new RenderElementBinder({variableBindings: new Map()}), [
directiveBinding({metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})}),
directiveBinding(
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}),
directiveBinding(
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})})
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})})
]);
}).not.toThrow();
});
@ -157,9 +162,9 @@ export function main() {
describe('createVariableLocations', () => {
it('should merge the names in the template for all ElementBinders', () => {
expect(createVariableLocations([
new renderApi.ElementBinder(
new RenderElementBinder(
{variableBindings: MapWrapper.createFromStringMap<string>({"x": "a"})}),
new renderApi.ElementBinder(
new RenderElementBinder(
{variableBindings: MapWrapper.createFromStringMap<string>({"y": "b"})})
])).toEqual(MapWrapper.createFromStringMap<number>({'a': 0, 'b': 1}));
@ -175,10 +180,10 @@ export function main() {
it("should return template event records", () => {
var rec = creator.getEventBindingRecords(
[
new renderApi.ElementBinder(
{eventBindings: [new renderApi.EventBinding("a", null)], directives: []}),
new renderApi.ElementBinder(
{eventBindings: [new renderApi.EventBinding("b", null)], directives: []})
new RenderElementBinder(
{eventBindings: [new EventBinding("a", null)], directives: []}),
new RenderElementBinder(
{eventBindings: [new EventBinding("b", null)], directives: []})
],
[]);
@ -191,17 +196,15 @@ export function main() {
it('should return host event records', () => {
var rec = creator.getEventBindingRecords(
[
new renderApi.ElementBinder({
new RenderElementBinder({
eventBindings: [],
directives: [
new renderApi.DirectiveBinder({
directiveIndex: 0,
eventBindings: [new renderApi.EventBinding("a", null)]
})
new DirectiveBinder(
{directiveIndex: 0, eventBindings: [new EventBinding("a", null)]})
]
})
],
[renderApi.DirectiveMetadata.create({id: 'some-id'})]);
[RenderDirectiveMetadata.create({id: 'some-id'})]);
expect(rec.length).toEqual(1);
expect(rec[0].eventName).toEqual("a");
@ -216,10 +219,10 @@ function directiveBinding({metadata}: {metadata?: any} = {}) {
return new DirectiveBinding(Key.get("dummy"), null, [], [], [], metadata);
}
function createRenderProtoView(elementBinders = null, type: renderApi.ViewType = null,
function createRenderProtoView(elementBinders = null, type: ViewType = null,
variableBindings = null) {
if (isBlank(type)) {
type = renderApi.ViewType.COMPONENT;
type = ViewType.COMPONENT;
}
if (isBlank(elementBinders)) {
elementBinders = [];
@ -227,7 +230,7 @@ function createRenderProtoView(elementBinders = null, type: renderApi.ViewType =
if (isBlank(variableBindings)) {
variableBindings = new Map();
}
return new renderApi.ProtoViewDto({
return new ProtoViewDto({
elementBinders: elementBinders,
type: type,
variableBindings: variableBindings,
@ -237,12 +240,12 @@ function createRenderProtoView(elementBinders = null, type: renderApi.ViewType =
}
function createRenderComponentElementBinder(directiveIndex) {
return new renderApi.ElementBinder(
{directives: [new renderApi.DirectiveBinder({directiveIndex: directiveIndex})]});
return new RenderElementBinder(
{directives: [new DirectiveBinder({directiveIndex: directiveIndex})]});
}
function createRenderViewportElementBinder(nestedProtoView) {
return new renderApi.ElementBinder({nestedProtoView: nestedProtoView});
return new RenderElementBinder({nestedProtoView: nestedProtoView});
}
@proxy

View File

@ -17,7 +17,7 @@ import {
import {Injectable, Optional} from 'angular2/di';
import {QueryList, TemplateRef} from 'angular2/core';
import {Query, ViewQuery, Component, Directive, View} from 'angular2/annotations';
import {Query, ViewQuery, Component, Directive, View} from 'angular2/metadata';
import {NgIf, NgFor} from 'angular2/angular2';

View File

@ -32,7 +32,7 @@ import {
ProtoElementInjector
} from 'angular2/src/core/compiler/element_injector';
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
import {Component} from 'angular2/annotations';
import {Component} from 'angular2/metadata';
import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils';
import {
RenderProtoViewMergeMapping,

View File

@ -13,7 +13,6 @@ import {
} from 'angular2/test_lib';
import {Directive, Component, View, LifecycleEvent} from 'angular2/angular2';
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
export function main() {
describe('directive lifecycle integration spec', () => {
@ -22,7 +21,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(
MyComp,
new viewAnn.View(
new View(
{template: '<div [field]="123" lifecycle></div>', directives: [LifecycleDir]}))
.createAsync(MyComp)
.then((tc) => {

View File

@ -11,7 +11,7 @@ import {
it,
xit
} from 'angular2/test_lib';
import {Directive, Component, Query, View} from 'angular2/annotations';
import {Directive, Component, Query, View} from 'angular2/metadata';
import {QueryList, NgFor} from 'angular2/angular2';
import {forwardRef, resolveForwardRef, bind, Inject} from 'angular2/di';
import {Type} from 'angular2/src/facade/lang';

View File

@ -11,7 +11,7 @@ import {
} from 'angular2/test_lib';
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
import {Pipe} from 'angular2/src/core/annotations_impl/annotations';
import {Pipe} from 'angular2/metadata';
class MyPipe {}

View File

@ -14,7 +14,7 @@ import {PipeTransform} from 'angular2/change_detection';
import {Injector, Inject, bind} from 'angular2/di';
import {ProtoPipes, Pipes} from 'angular2/src/core/pipes/pipes';
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
import {Pipe} from 'angular2/src/core/annotations_impl/annotations';
import {Pipe} from 'angular2/metadata';
class PipeA implements PipeTransform {
transform(a, b) {}

View File

@ -27,7 +27,7 @@ import {
Directive,
Component,
View,
} from 'angular2/annotations';
} from 'angular2/metadata';
import {NgFor} from 'angular2/src/directives/ng_for';

View File

@ -23,7 +23,7 @@ import {
Directive,
Component,
View,
} from 'angular2/annotations';
} from 'angular2/metadata';
import {IS_DART} from '../platform';
@Component({selector: 'my-comp'})

View File

@ -16,8 +16,6 @@ import {Component, View} from 'angular2/angular2';
import {isBlank} from 'angular2/src/facade/lang';
import * as viewImpl from 'angular2/src/core/annotations_impl/view';
export function main() {
describe('MockViewResolver', () => {
var viewResolver;
@ -32,7 +30,7 @@ export function main() {
});
it('should allow overriding the @View', () => {
viewResolver.setView(SomeComponent, new viewImpl.View({template: 'overridden template'}));
viewResolver.setView(SomeComponent, new View({template: 'overridden template'}));
var view = viewResolver.resolve(SomeComponent);
expect(view.template).toEqual('overridden template');
expect(isBlank(view.directives)).toBe(true);
@ -42,7 +40,7 @@ export function main() {
it('should not allow overriding a view after it has been resolved', () => {
viewResolver.resolve(SomeComponent);
expect(() => {
viewResolver.setView(SomeComponent, new viewImpl.View({template: 'overridden template'}));
viewResolver.setView(SomeComponent, new View({template: 'overridden template'}));
})
.toThrowError(
`The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
@ -58,7 +56,7 @@ export function main() {
});
it('should allow overriding an overriden @View', () => {
viewResolver.setView(SomeComponent, new viewImpl.View({template: 'overridden template'}));
viewResolver.setView(SomeComponent, new View({template: 'overridden template'}));
viewResolver.setInlineTemplate(SomeComponent, 'overridden template x 2');
var view = viewResolver.resolve(SomeComponent);
expect(view.template).toEqual('overridden template x 2');
@ -82,7 +80,7 @@ export function main() {
});
it('should allow overriding a directive from an overriden @View', () => {
viewResolver.setView(SomeComponent, new viewImpl.View({directives: [SomeOtherDirective]}));
viewResolver.setView(SomeComponent, new View({directives: [SomeOtherDirective]}));
viewResolver.overrideViewDirective(SomeComponent, SomeOtherDirective, SomeComponent);
var view = viewResolver.resolve(SomeComponent);
expect(view.directives.length).toEqual(1);

Some files were not shown because too many files have changed in this diff Show More