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:
parent
5e6317fecc
commit
ea6673947c
|
@ -5,7 +5,7 @@ module.exports = new Package('angular-v2-public-docs', [basePackage])
|
||||||
|
|
||||||
.config(function(readTypeScriptModules) {
|
.config(function(readTypeScriptModules) {
|
||||||
readTypeScriptModules.sourceFiles = [
|
readTypeScriptModules.sourceFiles = [
|
||||||
'angular2/annotations.ts',
|
'angular2/metadata.ts',
|
||||||
'angular2/change_detection.ts',
|
'angular2/change_detection.ts',
|
||||||
'angular2/core.ts',
|
'angular2/core.ts',
|
||||||
'angular2/di.ts',
|
'angular2/di.ts',
|
||||||
|
|
|
@ -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
|
// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs
|
||||||
// to resolve imports very very very slowly. See also a similar notice in
|
// to resolve imports very very very slowly. See also a similar notice in
|
||||||
// bootstrap.ts
|
// bootstrap.ts
|
||||||
export * from './annotations';
|
export * from './metadata';
|
||||||
export * from './change_detection';
|
export * from './change_detection';
|
||||||
export * from './core';
|
export * from './core';
|
||||||
export * from './di';
|
export * from './di';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export * from './annotations';
|
export * from './metadata';
|
||||||
export * from './change_detection';
|
export * from './change_detection';
|
||||||
export * from './core';
|
export * from './core';
|
||||||
export * from './di';
|
export * from './di';
|
||||||
|
|
|
@ -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';
|
|
|
@ -7,7 +7,7 @@ export {bootstrap} from 'angular2/src/core/application';
|
||||||
// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs
|
// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs
|
||||||
// to resolve imports very very very slowly. See also a similar notice in
|
// to resolve imports very very very slowly. See also a similar notice in
|
||||||
// angular2.ts
|
// angular2.ts
|
||||||
export * from './annotations';
|
export * from './metadata';
|
||||||
export * from './change_detection';
|
export * from './change_detection';
|
||||||
export * from './core';
|
export * from './core';
|
||||||
export * from './di';
|
export * from './di';
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
library angular2.metadata;
|
||||||
|
|
||||||
|
export 'package:angular2/src/core/metadata.dart';
|
||||||
|
export 'package:angular2/src/core/compiler/interfaces.dart';
|
|
@ -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';
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {
|
export {
|
||||||
DirectiveMetadata,
|
RenderDirectiveMetadata,
|
||||||
DomRenderer,
|
DomRenderer,
|
||||||
RenderEventDispatcher,
|
RenderEventDispatcher,
|
||||||
Renderer,
|
Renderer,
|
||||||
|
|
|
@ -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.
|
* has not changed.
|
||||||
*
|
*
|
||||||
* The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
|
* The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
|
||||||
|
|
|
@ -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";
|
|
|
@ -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';
|
|
|
@ -1,5 +0,0 @@
|
||||||
library angular2.core.decorators;
|
|
||||||
|
|
||||||
export '../annotations_impl/annotations.dart';
|
|
||||||
export '../annotations_impl/view.dart';
|
|
||||||
export '../annotations_impl/di.dart';
|
|
|
@ -1,3 +0,0 @@
|
||||||
library angular2.core.annotations.di;
|
|
||||||
|
|
||||||
export "../annotations_impl/di.dart";
|
|
|
@ -1,5 +0,0 @@
|
||||||
export {
|
|
||||||
Query as QueryAnnotation,
|
|
||||||
ViewQuery as ViewQueryAnnotation,
|
|
||||||
Attribute as AttributeAnnotation,
|
|
||||||
} from '../annotations_impl/di';
|
|
|
@ -1,3 +0,0 @@
|
||||||
library angular2.core.annotations.view;
|
|
||||||
|
|
||||||
export "../annotations_impl/view.dart";
|
|
|
@ -1 +0,0 @@
|
||||||
export {View as ViewAnnotation, ViewEncapsulation} from '../annotations_impl/view';
|
|
|
@ -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; }
|
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; }
|
get hostComponent(): any { return this._hostComponent.instance; }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {ProtoViewRef} from './view_ref';
|
||||||
import {DirectiveBinding} from './element_injector';
|
import {DirectiveBinding} from './element_injector';
|
||||||
import {ViewResolver} from './view_resolver';
|
import {ViewResolver} from './view_resolver';
|
||||||
import {PipeResolver} from './pipe_resolver';
|
import {PipeResolver} from './pipe_resolver';
|
||||||
import {View} from '../annotations_impl/view';
|
import {ViewMetadata} from 'angular2/metadata';
|
||||||
import {ComponentUrlMapper} from './component_url_mapper';
|
import {ComponentUrlMapper} from './component_url_mapper';
|
||||||
import {ProtoViewFactory} from './proto_view_factory';
|
import {ProtoViewFactory} from './proto_view_factory';
|
||||||
import {UrlResolver} from 'angular2/src/services/url_resolver';
|
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 {PipeBinding} from '../pipes/pipe_binding';
|
||||||
import {DEFAULT_PIPES_TOKEN} from 'angular2/pipes';
|
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.
|
* Cache that stores the AppProtoView of the template of a component.
|
||||||
|
@ -97,8 +104,8 @@ export class Compiler {
|
||||||
@Inject(DEFAULT_PIPES_TOKEN) _defaultPipes: Type[],
|
@Inject(DEFAULT_PIPES_TOKEN) _defaultPipes: Type[],
|
||||||
private _compilerCache: CompilerCache, private _viewResolver: ViewResolver,
|
private _compilerCache: CompilerCache, private _viewResolver: ViewResolver,
|
||||||
private _componentUrlMapper: ComponentUrlMapper, private _urlResolver: UrlResolver,
|
private _componentUrlMapper: ComponentUrlMapper, private _urlResolver: UrlResolver,
|
||||||
private _render: renderApi.RenderCompiler,
|
private _render: RenderCompiler, private _protoViewFactory: ProtoViewFactory,
|
||||||
private _protoViewFactory: ProtoViewFactory, appUrl: AppRootUrl) {
|
appUrl: AppRootUrl) {
|
||||||
this._defaultPipes = _defaultPipes;
|
this._defaultPipes = _defaultPipes;
|
||||||
this._appUrl = appUrl.value;
|
this._appUrl = appUrl.value;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +222,7 @@ export class Compiler {
|
||||||
componentPath: Map<Type, AppProtoView>): Promise<AppProtoView> {
|
componentPath: Map<Type, AppProtoView>): Promise<AppProtoView> {
|
||||||
var nestedPVPromises = [];
|
var nestedPVPromises = [];
|
||||||
componentPath = MapWrapper.clone(componentPath);
|
componentPath = MapWrapper.clone(componentPath);
|
||||||
if (appProtoViews[0].type === renderApi.ViewType.COMPONENT) {
|
if (appProtoViews[0].type === ViewType.COMPONENT) {
|
||||||
componentPath.set(componentType, appProtoViews[0]);
|
componentPath.set(componentType, appProtoViews[0]);
|
||||||
}
|
}
|
||||||
appProtoViews.forEach(appProtoView => {
|
appProtoViews.forEach(appProtoView => {
|
||||||
|
@ -230,7 +237,7 @@ export class Compiler {
|
||||||
if (appProtoView.isEmbeddedFragment) {
|
if (appProtoView.isEmbeddedFragment) {
|
||||||
throw new BaseException(
|
throw new BaseException(
|
||||||
`<ng-content> is used within the recursive path of ${stringify(nestedComponentType)}`);
|
`<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(
|
throw new BaseException(
|
||||||
`Unconditional component cycle in ${stringify(nestedComponentType)}`);
|
`Unconditional component cycle in ${stringify(nestedComponentType)}`);
|
||||||
} else {
|
} else {
|
||||||
|
@ -253,18 +260,17 @@ export class Compiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _mergeProtoView(appProtoView: AppProtoView): Promise<any> {
|
private _mergeProtoView(appProtoView: AppProtoView): Promise<any> {
|
||||||
if (appProtoView.type !== renderApi.ViewType.HOST &&
|
if (appProtoView.type !== ViewType.HOST && appProtoView.type !== ViewType.EMBEDDED) {
|
||||||
appProtoView.type !== renderApi.ViewType.EMBEDDED) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this._render.mergeProtoViewsRecursively(this._collectMergeRenderProtoViews(appProtoView))
|
return this._render.mergeProtoViewsRecursively(this._collectMergeRenderProtoViews(appProtoView))
|
||||||
.then((mergeResult: renderApi.RenderProtoViewMergeMapping) => {
|
.then((mergeResult: RenderProtoViewMergeMapping) => {
|
||||||
appProtoView.mergeMapping = new AppProtoViewMergeMapping(mergeResult);
|
appProtoView.mergeMapping = new AppProtoViewMergeMapping(mergeResult);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _collectMergeRenderProtoViews(
|
private _collectMergeRenderProtoViews(appProtoView:
|
||||||
appProtoView: AppProtoView): List<renderApi.RenderProtoViewRef | List<any>> {
|
AppProtoView): List<RenderProtoViewRef | List<any>> {
|
||||||
var result = [appProtoView.render];
|
var result = [appProtoView.render];
|
||||||
for (var i = 0; i < appProtoView.elementBinders.length; i++) {
|
for (var i = 0; i < appProtoView.elementBinders.length; i++) {
|
||||||
var binder = appProtoView.elementBinders[i];
|
var binder = appProtoView.elementBinders[i];
|
||||||
|
@ -290,7 +296,7 @@ export class Compiler {
|
||||||
return componentElementBinders;
|
return componentElementBinders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _buildRenderTemplate(component, view, directives): renderApi.ViewDefinition {
|
private _buildRenderTemplate(component, view, directives): ViewDefinition {
|
||||||
var componentUrl =
|
var componentUrl =
|
||||||
this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component));
|
this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component));
|
||||||
var templateAbsUrl = null;
|
var templateAbsUrl = null;
|
||||||
|
@ -307,7 +313,7 @@ export class Compiler {
|
||||||
styleAbsUrls =
|
styleAbsUrls =
|
||||||
ListWrapper.map(view.styleUrls, url => this._urlResolver.resolve(componentUrl, url));
|
ListWrapper.map(view.styleUrls, url => this._urlResolver.resolve(componentUrl, url));
|
||||||
}
|
}
|
||||||
return new renderApi.ViewDefinition({
|
return new ViewDefinition({
|
||||||
componentId: stringify(component),
|
componentId: stringify(component),
|
||||||
templateAbsUrl: templateAbsUrl, template: view.template,
|
templateAbsUrl: templateAbsUrl, template: view.template,
|
||||||
styleAbsUrls: styleAbsUrls,
|
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;
|
if (isBlank(view.pipes)) return this._defaultPipes;
|
||||||
var pipes = ListWrapper.clone(this._defaultPipes);
|
var pipes = ListWrapper.clone(this._defaultPipes);
|
||||||
this._flattenList(view.pipes, pipes);
|
this._flattenList(view.pipes, pipes);
|
||||||
return pipes;
|
return pipes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _flattenDirectives(view: View): List<Type> {
|
private _flattenDirectives(view: ViewMetadata): List<Type> {
|
||||||
if (isBlank(view.directives)) return [];
|
if (isBlank(view.directives)) return [];
|
||||||
var directives = [];
|
var directives = [];
|
||||||
this._flattenList(view.directives, directives);
|
this._flattenList(view.directives, directives);
|
||||||
|
@ -347,7 +353,7 @@ export class Compiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _assertTypeIsComponent(directiveBinding: DirectiveBinding): void {
|
private static _assertTypeIsComponent(directiveBinding: DirectiveBinding): void {
|
||||||
if (directiveBinding.metadata.type !== renderApi.DirectiveMetadata.COMPONENT_TYPE) {
|
if (directiveBinding.metadata.type !== RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||||
throw new BaseException(
|
throw new BaseException(
|
||||||
`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
|
`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Type, isPresent} from 'angular2/src/facade/lang';
|
||||||
import {Map, MapWrapper} from 'angular2/src/facade/collection';
|
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.
|
* This interface can be overridden by the application developer to create custom behavior.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
library angular2.src.core.compiler.directive_lifecycle_reflector;
|
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/core/compiler/interfaces.dart';
|
||||||
import 'package:angular2/src/reflection/reflection.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) {
|
if (annotation.lifecycle != null) {
|
||||||
return annotation.lifecycle.contains(e);
|
return annotation.lifecycle.contains(e);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {Type, isPresent} from 'angular2/src/facade/lang';
|
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)) {
|
if (isPresent(annotation.lifecycle)) {
|
||||||
return annotation.lifecycle.indexOf(e) !== -1;
|
return annotation.lifecycle.indexOf(e) !== -1;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import {resolveForwardRef, Injectable} from 'angular2/di';
|
import {resolveForwardRef, Injectable} from 'angular2/di';
|
||||||
import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
|
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';
|
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.
|
* 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()
|
@Injectable()
|
||||||
export class DirectiveResolver {
|
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));
|
var annotations = reflector.annotations(resolveForwardRef(type));
|
||||||
if (isPresent(annotations)) {
|
if (isPresent(annotations)) {
|
||||||
for (var i = 0; i < annotations.length; i++) {
|
for (var i = 0; i < annotations.length; i++) {
|
||||||
var annotation = annotations[i];
|
var annotation = annotations[i];
|
||||||
if (annotation instanceof Directive) {
|
if (annotation instanceof DirectiveMetadata) {
|
||||||
return annotation;
|
return annotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,19 +31,19 @@ import {
|
||||||
BindingWithVisibility
|
BindingWithVisibility
|
||||||
} from 'angular2/src/di/injector';
|
} 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 viewModule from './view';
|
||||||
import * as avmModule from './view_manager';
|
import * as avmModule from './view_manager';
|
||||||
import {ViewContainerRef} from './view_container_ref';
|
import {ViewContainerRef} from './view_container_ref';
|
||||||
import {ElementRef} from './element_ref';
|
import {ElementRef} from './element_ref';
|
||||||
import {TemplateRef} from './template_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 {hasLifecycleHook} from './directive_lifecycle_reflector';
|
||||||
import {ChangeDetector, ChangeDetectorRef} from 'angular2/src/change_detection/change_detection';
|
import {ChangeDetector, ChangeDetectorRef} from 'angular2/src/change_detection/change_detection';
|
||||||
import {QueryList} from './query_list';
|
import {QueryList} from './query_list';
|
||||||
import {reflector} from 'angular2/src/reflection/reflection';
|
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';
|
import {PipeBinding} from '../pipes/pipe_binding';
|
||||||
|
|
||||||
var _staticKeys;
|
var _staticKeys;
|
||||||
|
@ -160,7 +160,7 @@ export class TreeNode<T extends TreeNode<any>> {
|
||||||
export class DirectiveDependency extends Dependency {
|
export class DirectiveDependency extends Dependency {
|
||||||
constructor(key: Key, optional: boolean, lowerBoundVisibility: Object,
|
constructor(key: Key, optional: boolean, lowerBoundVisibility: Object,
|
||||||
upperBoundVisibility: Object, properties: List<any>, public attributeName: string,
|
upperBoundVisibility: Object, properties: List<any>, public attributeName: string,
|
||||||
public queryDecorator: Query) {
|
public queryDecorator: QueryMetadata) {
|
||||||
super(key, optional, lowerBoundVisibility, upperBoundVisibility, properties);
|
super(key, optional, lowerBoundVisibility, upperBoundVisibility, properties);
|
||||||
this._verify();
|
this._verify();
|
||||||
}
|
}
|
||||||
|
@ -181,12 +181,12 @@ export class DirectiveDependency extends Dependency {
|
||||||
}
|
}
|
||||||
|
|
||||||
static _attributeName(properties): string {
|
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;
|
return isPresent(p) ? p.attributeName : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static _query(properties): Query {
|
static _query(properties): QueryMetadata {
|
||||||
return <Query>ListWrapper.find(properties, (p) => p instanceof Query);
|
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>,
|
constructor(key: Key, factory: Function, dependencies: List<Dependency>,
|
||||||
public resolvedBindings: List<ResolvedBinding>,
|
public resolvedBindings: List<ResolvedBinding>,
|
||||||
public resolvedViewBindings: List<ResolvedBinding>,
|
public resolvedViewBindings: List<ResolvedBinding>,
|
||||||
public metadata: DirectiveMetadata) {
|
public metadata: RenderDirectiveMetadata) {
|
||||||
super(key, factory, dependencies);
|
super(key, factory, dependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,21 +218,21 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||||
|
|
||||||
get changeDetection() { return this.metadata.changeDetection; }
|
get changeDetection() { return this.metadata.changeDetection; }
|
||||||
|
|
||||||
static createFromBinding(binding: Binding, ann: Directive): DirectiveBinding {
|
static createFromBinding(binding: Binding, ann: DirectiveMetadata): DirectiveBinding {
|
||||||
if (isBlank(ann)) {
|
if (isBlank(ann)) {
|
||||||
ann = new Directive();
|
ann = new DirectiveMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
var rb = binding.resolve();
|
var rb = binding.resolve();
|
||||||
var deps = ListWrapper.map(rb.dependencies, DirectiveDependency.createFrom);
|
var deps = ListWrapper.map(rb.dependencies, DirectiveDependency.createFrom);
|
||||||
var resolvedBindings = isPresent(ann.bindings) ? Injector.resolve(ann.bindings) : [];
|
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) :
|
Injector.resolve(ann.viewBindings) :
|
||||||
[];
|
[];
|
||||||
var metadata = DirectiveMetadata.create({
|
var metadata = RenderDirectiveMetadata.create({
|
||||||
id: stringify(rb.key.token),
|
id: stringify(rb.key.token),
|
||||||
type: ann instanceof Component ? DirectiveMetadata.COMPONENT_TYPE :
|
type: ann instanceof ComponentMetadata ? RenderDirectiveMetadata.COMPONENT_TYPE :
|
||||||
DirectiveMetadata.DIRECTIVE_TYPE,
|
RenderDirectiveMetadata.DIRECTIVE_TYPE,
|
||||||
selector: ann.selector,
|
selector: ann.selector,
|
||||||
compileChildren: ann.compileChildren,
|
compileChildren: ann.compileChildren,
|
||||||
events: ann.events,
|
events: ann.events,
|
||||||
|
@ -246,7 +246,7 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||||
callOnInit: hasLifecycleHook(LifecycleEvent.onInit, rb.key.token, ann),
|
callOnInit: hasLifecycleHook(LifecycleEvent.onInit, rb.key.token, ann),
|
||||||
callOnAllChangesDone: hasLifecycleHook(LifecycleEvent.onAllChangesDone, 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
|
exportAs: ann.exportAs
|
||||||
});
|
});
|
||||||
|
@ -264,7 +264,7 @@ export class DirectiveBinding extends ResolvedBinding {
|
||||||
return readAttributes;
|
return readAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static createFromType(type: Type, annotation: Directive): DirectiveBinding {
|
static createFromType(type: Type, annotation: DirectiveMetadata): DirectiveBinding {
|
||||||
var binding = new Binding(type, {toClass: type});
|
var binding = new Binding(type, {toClass: type});
|
||||||
return DirectiveBinding.createFromBinding(binding, annotation);
|
return DirectiveBinding.createFromBinding(binding, annotation);
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
||||||
if (dirDep.key.id === StaticKeys.instance().changeDetectorRefId) {
|
if (dirDep.key.id === StaticKeys.instance().changeDetectorRefId) {
|
||||||
// We provide the component's view change detector to components and
|
// We provide the component's view change detector to components and
|
||||||
// the surrounding component's change detector to directives.
|
// 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(
|
var componentView = this._preBuiltObjects.view.getNestedView(
|
||||||
this._preBuiltObjects.elementRef.boundElementIndex);
|
this._preBuiltObjects.elementRef.boundElementIndex);
|
||||||
return componentView.changeDetector.ref;
|
return componentView.changeDetector.ref;
|
||||||
|
@ -713,7 +713,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
||||||
matched.forEach(s => queryRef.list.add(s));
|
matched.forEach(s => queryRef.list.add(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createQueryRef(query: Query): void {
|
private _createQueryRef(query: QueryMetadata): void {
|
||||||
var queryList = new QueryList<any>();
|
var queryList = new QueryList<any>();
|
||||||
if (isBlank(this._query0)) {
|
if (isBlank(this._query0)) {
|
||||||
this._query0 = new QueryRef(query, queryList, this);
|
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;
|
var templateRef = this._preBuiltObjects.templateRef;
|
||||||
if (query.selector === TemplateRef && isPresent(templateRef)) {
|
if (query.selector === TemplateRef && isPresent(templateRef)) {
|
||||||
list.push(templateRef);
|
list.push(templateRef);
|
||||||
|
@ -873,7 +873,7 @@ interface _ElementInjectorStrategy {
|
||||||
getComponent(): any;
|
getComponent(): any;
|
||||||
isComponentKey(key: Key): boolean;
|
isComponentKey(key: Key): boolean;
|
||||||
buildQueries(): void;
|
buildQueries(): void;
|
||||||
addDirectivesMatchingQuery(q: Query, res: any[]): void;
|
addDirectivesMatchingQuery(q: QueryMetadata, res: any[]): void;
|
||||||
getComponentBinding(): DirectiveBinding;
|
getComponentBinding(): DirectiveBinding;
|
||||||
hydrate(): void;
|
hydrate(): void;
|
||||||
dehydrate(): 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 i = this.injectorStrategy;
|
||||||
var p = i.protoStrategy;
|
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 ist = this.injectorStrategy;
|
||||||
var p = ist.protoStrategy;
|
var p = ist.protoStrategy;
|
||||||
|
|
||||||
|
@ -1144,7 +1144,7 @@ export class QueryError extends BaseException {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class QueryRef {
|
export class QueryRef {
|
||||||
constructor(public query: Query, public list: QueryList<any>,
|
constructor(public query: QueryMetadata, public list: QueryList<any>,
|
||||||
public originator: ElementInjector) {}
|
public originator: ElementInjector) {}
|
||||||
|
|
||||||
get isViewQuery(): boolean { return this.query.isViewQuery; }
|
get isViewQuery(): boolean { return this.query.isViewQuery; }
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import {resolveForwardRef, Injectable} from 'angular2/di';
|
import {resolveForwardRef, Injectable} from 'angular2/di';
|
||||||
import {Type, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
|
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';
|
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.
|
* 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()
|
@Injectable()
|
||||||
export class PipeResolver {
|
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));
|
var metas = reflector.annotations(resolveForwardRef(type));
|
||||||
if (isPresent(metas)) {
|
if (isPresent(metas)) {
|
||||||
for (var i = 0; i < metas.length; i++) {
|
for (var i = 0; i < metas.length; i++) {
|
||||||
var annotation = metas[i];
|
var annotation = metas[i];
|
||||||
if (annotation instanceof Pipe) {
|
if (annotation instanceof PipeMetadata) {
|
||||||
return annotation;
|
return annotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,14 @@ import {
|
||||||
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
|
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
|
||||||
import {ProtoPipes} from 'angular2/src/core/pipes/pipes';
|
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 {AppProtoView} from './view';
|
||||||
import {ElementBinder} from './element_binder';
|
import {ElementBinder} from './element_binder';
|
||||||
import {ProtoElementInjector, DirectiveBinding} from './element_injector';
|
import {ProtoElementInjector, DirectiveBinding} from './element_injector';
|
||||||
|
@ -26,8 +33,8 @@ import {ProtoElementInjector, DirectiveBinding} from './element_injector';
|
||||||
export class BindingRecordsCreator {
|
export class BindingRecordsCreator {
|
||||||
_directiveRecordsMap: Map<number, DirectiveRecord> = new Map();
|
_directiveRecordsMap: Map<number, DirectiveRecord> = new Map();
|
||||||
|
|
||||||
getEventBindingRecords(elementBinders: List<renderApi.ElementBinder>,
|
getEventBindingRecords(elementBinders: List<RenderElementBinder>,
|
||||||
allDirectiveMetadatas: renderApi.DirectiveMetadata[]): BindingRecord[] {
|
allDirectiveMetadatas: RenderDirectiveMetadata[]): BindingRecord[] {
|
||||||
var res = [];
|
var res = [];
|
||||||
for (var boundElementIndex = 0; boundElementIndex < elementBinders.length;
|
for (var boundElementIndex = 0; boundElementIndex < elementBinders.length;
|
||||||
boundElementIndex++) {
|
boundElementIndex++) {
|
||||||
|
@ -41,16 +48,15 @@ export class BindingRecordsCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createTemplateEventRecords(res: BindingRecord[],
|
private _createTemplateEventRecords(res: BindingRecord[],
|
||||||
renderElementBinder: renderApi.ElementBinder,
|
renderElementBinder: RenderElementBinder,
|
||||||
boundElementIndex: number): void {
|
boundElementIndex: number): void {
|
||||||
renderElementBinder.eventBindings.forEach(eb => {
|
renderElementBinder.eventBindings.forEach(eb => {
|
||||||
res.push(BindingRecord.createForEvent(eb.source, eb.fullName, boundElementIndex));
|
res.push(BindingRecord.createForEvent(eb.source, eb.fullName, boundElementIndex));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _createHostEventRecords(res: BindingRecord[],
|
private _createHostEventRecords(res: BindingRecord[], renderElementBinder: RenderElementBinder,
|
||||||
renderElementBinder: renderApi.ElementBinder,
|
allDirectiveMetadatas: RenderDirectiveMetadata[],
|
||||||
allDirectiveMetadatas: renderApi.DirectiveMetadata[],
|
|
||||||
boundElementIndex: number): void {
|
boundElementIndex: number): void {
|
||||||
for (var i = 0; i < renderElementBinder.directives.length; ++i) {
|
for (var i = 0; i < renderElementBinder.directives.length; ++i) {
|
||||||
var dir = renderElementBinder.directives[i];
|
var dir = renderElementBinder.directives[i];
|
||||||
|
@ -63,9 +69,9 @@ export class BindingRecordsCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
getPropertyBindingRecords(textBindings: List<ASTWithSource>,
|
getPropertyBindingRecords(textBindings: List<ASTWithSource>,
|
||||||
elementBinders: List<renderApi.ElementBinder>,
|
elementBinders: List<RenderElementBinder>,
|
||||||
allDirectiveMetadatas:
|
allDirectiveMetadatas:
|
||||||
List<renderApi.DirectiveMetadata>): List<BindingRecord> {
|
List<RenderDirectiveMetadata>): List<BindingRecord> {
|
||||||
var bindings = [];
|
var bindings = [];
|
||||||
|
|
||||||
this._createTextNodeRecords(bindings, textBindings);
|
this._createTextNodeRecords(bindings, textBindings);
|
||||||
|
@ -80,9 +86,8 @@ export class BindingRecordsCreator {
|
||||||
return bindings;
|
return bindings;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDirectiveRecords(elementBinders: List<renderApi.ElementBinder>,
|
getDirectiveRecords(elementBinders: List<RenderElementBinder>,
|
||||||
allDirectiveMetadatas:
|
allDirectiveMetadatas: List<RenderDirectiveMetadata>): List<DirectiveRecord> {
|
||||||
List<renderApi.DirectiveMetadata>): List<DirectiveRecord> {
|
|
||||||
var directiveRecords = [];
|
var directiveRecords = [];
|
||||||
|
|
||||||
for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) {
|
for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) {
|
||||||
|
@ -103,18 +108,18 @@ export class BindingRecordsCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createElementPropertyRecords(bindings: List<BindingRecord>, boundElementIndex: number,
|
_createElementPropertyRecords(bindings: List<BindingRecord>, boundElementIndex: number,
|
||||||
renderElementBinder: renderApi.ElementBinder) {
|
renderElementBinder: RenderElementBinder) {
|
||||||
ListWrapper.forEach(renderElementBinder.propertyBindings, (binding) => {
|
ListWrapper.forEach(renderElementBinder.propertyBindings, (binding) => {
|
||||||
if (binding.type === renderApi.PropertyBindingType.PROPERTY) {
|
if (binding.type === PropertyBindingType.PROPERTY) {
|
||||||
bindings.push(BindingRecord.createForElementProperty(binding.astWithSource,
|
bindings.push(BindingRecord.createForElementProperty(binding.astWithSource,
|
||||||
boundElementIndex, binding.property));
|
boundElementIndex, binding.property));
|
||||||
} else if (binding.type === renderApi.PropertyBindingType.ATTRIBUTE) {
|
} else if (binding.type === PropertyBindingType.ATTRIBUTE) {
|
||||||
bindings.push(BindingRecord.createForElementAttribute(binding.astWithSource,
|
bindings.push(BindingRecord.createForElementAttribute(binding.astWithSource,
|
||||||
boundElementIndex, binding.property));
|
boundElementIndex, binding.property));
|
||||||
} else if (binding.type === renderApi.PropertyBindingType.CLASS) {
|
} else if (binding.type === PropertyBindingType.CLASS) {
|
||||||
bindings.push(BindingRecord.createForElementClass(binding.astWithSource, boundElementIndex,
|
bindings.push(BindingRecord.createForElementClass(binding.astWithSource, boundElementIndex,
|
||||||
binding.property));
|
binding.property));
|
||||||
} else if (binding.type === renderApi.PropertyBindingType.STYLE) {
|
} else if (binding.type === PropertyBindingType.STYLE) {
|
||||||
bindings.push(BindingRecord.createForElementStyle(binding.astWithSource, boundElementIndex,
|
bindings.push(BindingRecord.createForElementStyle(binding.astWithSource, boundElementIndex,
|
||||||
binding.property, binding.unit));
|
binding.property, binding.unit));
|
||||||
}
|
}
|
||||||
|
@ -122,8 +127,8 @@ export class BindingRecordsCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createDirectiveRecords(bindings: List<BindingRecord>, boundElementIndex: number,
|
_createDirectiveRecords(bindings: List<BindingRecord>, boundElementIndex: number,
|
||||||
directiveBinders: List<renderApi.DirectiveBinder>,
|
directiveBinders: List<DirectiveBinder>,
|
||||||
allDirectiveMetadatas: List<renderApi.DirectiveMetadata>) {
|
allDirectiveMetadatas: List<RenderDirectiveMetadata>) {
|
||||||
for (var i = 0; i < directiveBinders.length; i++) {
|
for (var i = 0; i < directiveBinders.length; i++) {
|
||||||
var directiveBinder = directiveBinders[i];
|
var directiveBinder = directiveBinders[i];
|
||||||
var directiveMetadata = allDirectiveMetadatas[directiveBinder.directiveIndex];
|
var directiveMetadata = allDirectiveMetadatas[directiveBinder.directiveIndex];
|
||||||
|
@ -154,16 +159,16 @@ export class BindingRecordsCreator {
|
||||||
// host properties
|
// host properties
|
||||||
ListWrapper.forEach(directiveBinder.hostPropertyBindings, (binding) => {
|
ListWrapper.forEach(directiveBinder.hostPropertyBindings, (binding) => {
|
||||||
var dirIndex = new DirectiveIndex(boundElementIndex, i);
|
var dirIndex = new DirectiveIndex(boundElementIndex, i);
|
||||||
if (binding.type === renderApi.PropertyBindingType.PROPERTY) {
|
if (binding.type === PropertyBindingType.PROPERTY) {
|
||||||
bindings.push(BindingRecord.createForHostProperty(dirIndex, binding.astWithSource,
|
bindings.push(BindingRecord.createForHostProperty(dirIndex, binding.astWithSource,
|
||||||
binding.property));
|
binding.property));
|
||||||
} else if (binding.type === renderApi.PropertyBindingType.ATTRIBUTE) {
|
} else if (binding.type === PropertyBindingType.ATTRIBUTE) {
|
||||||
bindings.push(BindingRecord.createForHostAttribute(dirIndex, binding.astWithSource,
|
bindings.push(BindingRecord.createForHostAttribute(dirIndex, binding.astWithSource,
|
||||||
binding.property));
|
binding.property));
|
||||||
} else if (binding.type === renderApi.PropertyBindingType.CLASS) {
|
} else if (binding.type === PropertyBindingType.CLASS) {
|
||||||
bindings.push(
|
bindings.push(
|
||||||
BindingRecord.createForHostClass(dirIndex, binding.astWithSource, binding.property));
|
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,
|
bindings.push(BindingRecord.createForHostStyle(dirIndex, binding.astWithSource,
|
||||||
binding.property, binding.unit));
|
binding.property, binding.unit));
|
||||||
}
|
}
|
||||||
|
@ -172,7 +177,7 @@ export class BindingRecordsCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getDirectiveRecord(boundElementIndex: number, directiveIndex: number,
|
_getDirectiveRecord(boundElementIndex: number, directiveIndex: number,
|
||||||
directiveMetadata: renderApi.DirectiveMetadata): DirectiveRecord {
|
directiveMetadata: RenderDirectiveMetadata): DirectiveRecord {
|
||||||
var id = boundElementIndex * 100 + directiveIndex;
|
var id = boundElementIndex * 100 + directiveIndex;
|
||||||
|
|
||||||
if (!this._directiveRecordsMap.has(id)) {
|
if (!this._directiveRecordsMap.has(id)) {
|
||||||
|
@ -198,8 +203,7 @@ export class ProtoViewFactory {
|
||||||
*/
|
*/
|
||||||
constructor(public _changeDetection: ChangeDetection) {}
|
constructor(public _changeDetection: ChangeDetection) {}
|
||||||
|
|
||||||
createAppProtoViews(hostComponentBinding: DirectiveBinding,
|
createAppProtoViews(hostComponentBinding: DirectiveBinding, rootRenderProtoView: ProtoViewDto,
|
||||||
rootRenderProtoView: renderApi.ProtoViewDto,
|
|
||||||
allDirectives: List<DirectiveBinding>, pipes: PipeBinding[]): AppProtoView[] {
|
allDirectives: List<DirectiveBinding>, pipes: PipeBinding[]): AppProtoView[] {
|
||||||
var allRenderDirectiveMetadata =
|
var allRenderDirectiveMetadata =
|
||||||
ListWrapper.map(allDirectives, directiveBinding => directiveBinding.metadata);
|
ListWrapper.map(allDirectives, directiveBinding => directiveBinding.metadata);
|
||||||
|
@ -233,8 +237,8 @@ export class ProtoViewFactory {
|
||||||
* for the given ProtoView and all nested ProtoViews.
|
* for the given ProtoView and all nested ProtoViews.
|
||||||
*/
|
*/
|
||||||
export function getChangeDetectorDefinitions(
|
export function getChangeDetectorDefinitions(
|
||||||
hostComponentMetadata: renderApi.DirectiveMetadata, rootRenderProtoView: renderApi.ProtoViewDto,
|
hostComponentMetadata: RenderDirectiveMetadata, rootRenderProtoView: ProtoViewDto,
|
||||||
allRenderDirectiveMetadata: List<renderApi.DirectiveMetadata>): List<ChangeDetectorDefinition> {
|
allRenderDirectiveMetadata: List<RenderDirectiveMetadata>): List<ChangeDetectorDefinition> {
|
||||||
var nestedPvsWithIndex = _collectNestedProtoViews(rootRenderProtoView);
|
var nestedPvsWithIndex = _collectNestedProtoViews(rootRenderProtoView);
|
||||||
var nestedPvVariableNames = _collectNestedProtoViewsVariableNames(nestedPvsWithIndex);
|
var nestedPvVariableNames = _collectNestedProtoViewsVariableNames(nestedPvsWithIndex);
|
||||||
return _getChangeDetectorDefinitions(hostComponentMetadata, nestedPvsWithIndex,
|
return _getChangeDetectorDefinitions(hostComponentMetadata, nestedPvsWithIndex,
|
||||||
|
@ -242,7 +246,7 @@ export function getChangeDetectorDefinitions(
|
||||||
}
|
}
|
||||||
|
|
||||||
function _collectNestedProtoViews(
|
function _collectNestedProtoViews(
|
||||||
renderProtoView: renderApi.ProtoViewDto, parentIndex: number = null, boundElementIndex = null,
|
renderProtoView: ProtoViewDto, parentIndex: number = null, boundElementIndex = null,
|
||||||
result: List<RenderProtoViewWithIndex> = null): List<RenderProtoViewWithIndex> {
|
result: List<RenderProtoViewWithIndex> = null): List<RenderProtoViewWithIndex> {
|
||||||
if (isBlank(result)) {
|
if (isBlank(result)) {
|
||||||
result = [];
|
result = [];
|
||||||
|
@ -263,9 +267,9 @@ function _collectNestedProtoViews(
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getChangeDetectorDefinitions(
|
function _getChangeDetectorDefinitions(
|
||||||
hostComponentMetadata: renderApi.DirectiveMetadata,
|
hostComponentMetadata: RenderDirectiveMetadata,
|
||||||
nestedPvsWithIndex: List<RenderProtoViewWithIndex>, nestedPvVariableNames: List<List<string>>,
|
nestedPvsWithIndex: List<RenderProtoViewWithIndex>, nestedPvVariableNames: List<List<string>>,
|
||||||
allRenderDirectiveMetadata: List<renderApi.DirectiveMetadata>): List<ChangeDetectorDefinition> {
|
allRenderDirectiveMetadata: List<RenderDirectiveMetadata>): List<ChangeDetectorDefinition> {
|
||||||
return ListWrapper.map(nestedPvsWithIndex, (pvWithIndex) => {
|
return ListWrapper.map(nestedPvsWithIndex, (pvWithIndex) => {
|
||||||
var elementBinders = pvWithIndex.renderProtoView.elementBinders;
|
var elementBinders = pvWithIndex.renderProtoView.elementBinders;
|
||||||
var bindingRecordsCreator = new BindingRecordsCreator();
|
var bindingRecordsCreator = new BindingRecordsCreator();
|
||||||
|
@ -277,10 +281,10 @@ function _getChangeDetectorDefinitions(
|
||||||
bindingRecordsCreator.getDirectiveRecords(elementBinders, allRenderDirectiveMetadata);
|
bindingRecordsCreator.getDirectiveRecords(elementBinders, allRenderDirectiveMetadata);
|
||||||
var strategyName = DEFAULT;
|
var strategyName = DEFAULT;
|
||||||
var typeString;
|
var typeString;
|
||||||
if (pvWithIndex.renderProtoView.type === renderApi.ViewType.COMPONENT) {
|
if (pvWithIndex.renderProtoView.type === ViewType.COMPONENT) {
|
||||||
strategyName = hostComponentMetadata.changeDetection;
|
strategyName = hostComponentMetadata.changeDetection;
|
||||||
typeString = 'comp';
|
typeString = 'comp';
|
||||||
} else if (pvWithIndex.renderProtoView.type === renderApi.ViewType.HOST) {
|
} else if (pvWithIndex.renderProtoView.type === ViewType.HOST) {
|
||||||
typeString = 'host';
|
typeString = 'host';
|
||||||
} else {
|
} else {
|
||||||
typeString = 'embedded';
|
typeString = 'embedded';
|
||||||
|
@ -293,7 +297,7 @@ function _getChangeDetectorDefinitions(
|
||||||
}
|
}
|
||||||
|
|
||||||
function _createAppProtoView(
|
function _createAppProtoView(
|
||||||
renderProtoView: renderApi.ProtoViewDto, protoChangeDetector: ProtoChangeDetector,
|
renderProtoView: ProtoViewDto, protoChangeDetector: ProtoChangeDetector,
|
||||||
variableBindings: Map<string, string>, allDirectives: List<DirectiveBinding>,
|
variableBindings: Map<string, string>, allDirectives: List<DirectiveBinding>,
|
||||||
pipes: PipeBinding[]): AppProtoView {
|
pipes: PipeBinding[]): AppProtoView {
|
||||||
var elementBinders = renderProtoView.elementBinders;
|
var elementBinders = renderProtoView.elementBinders;
|
||||||
|
@ -346,7 +350,7 @@ function _createVariableNames(parentVariableNames: List<string>, renderProtoView
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createVariableLocations(elementBinders: List<renderApi.ElementBinder>):
|
export function createVariableLocations(elementBinders: List<RenderElementBinder>):
|
||||||
Map<string, number> {
|
Map<string, number> {
|
||||||
var variableLocations = new Map();
|
var variableLocations = new Map();
|
||||||
for (var i = 0; i < elementBinders.length; i++) {
|
for (var i = 0; i < elementBinders.length; i++) {
|
||||||
|
@ -368,7 +372,7 @@ function _createElementBinders(protoView, elementBinders, allDirectiveBindings)
|
||||||
ListWrapper.map(dirs, (dir) => allDirectiveBindings[dir.directiveIndex]);
|
ListWrapper.map(dirs, (dir) => allDirectiveBindings[dir.directiveIndex]);
|
||||||
var componentDirectiveBinding = null;
|
var componentDirectiveBinding = null;
|
||||||
if (directiveBindings.length > 0) {
|
if (directiveBindings.length > 0) {
|
||||||
if (directiveBindings[0].metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
|
if (directiveBindings[0].metadata.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||||
componentDirectiveBinding = directiveBindings[0];
|
componentDirectiveBinding = directiveBindings[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,7 +443,7 @@ function _createElementBinder(protoView: AppProtoView, boundElementIndex, render
|
||||||
return elBinder;
|
return elBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createDirectiveVariableBindings(renderElementBinder: renderApi.ElementBinder,
|
export function createDirectiveVariableBindings(renderElementBinder: RenderElementBinder,
|
||||||
directiveBindings: List<DirectiveBinding>):
|
directiveBindings: List<DirectiveBinding>):
|
||||||
Map<string, number> {
|
Map<string, number> {
|
||||||
var directiveVariableBindings = new Map();
|
var directiveVariableBindings = new Map();
|
||||||
|
@ -478,7 +482,7 @@ function _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, e
|
||||||
function _directiveExportAs(directive): string {
|
function _directiveExportAs(directive): string {
|
||||||
var directiveExportAs = directive.metadata.exportAs;
|
var directiveExportAs = directive.metadata.exportAs;
|
||||||
if (isBlank(directiveExportAs) &&
|
if (isBlank(directiveExportAs) &&
|
||||||
directive.metadata.type === renderApi.DirectiveMetadata.COMPONENT_TYPE) {
|
directive.metadata.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||||
return "$implicit";
|
return "$implicit";
|
||||||
} else {
|
} else {
|
||||||
return directiveExportAs;
|
return directiveExportAs;
|
||||||
|
@ -486,7 +490,7 @@ function _directiveExportAs(directive): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
class RenderProtoViewWithIndex {
|
class RenderProtoViewWithIndex {
|
||||||
constructor(public renderProtoView: renderApi.ProtoViewDto, public index: number,
|
constructor(public renderProtoView: ProtoViewDto, public index: number,
|
||||||
public parentIndex: number, public boundElementIndex: number) {}
|
public parentIndex: number, public boundElementIndex: number) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {Injectable} from 'angular2/di';
|
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 {Type, stringify, isBlank, BaseException} from 'angular2/src/facade/lang';
|
||||||
import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
|
import {Map, MapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
|
@ -11,7 +11,7 @@ import {reflector} from 'angular2/src/reflection/reflection';
|
||||||
export class ViewResolver {
|
export class ViewResolver {
|
||||||
_cache: Map<Type, /*node*/ any> = new Map();
|
_cache: Map<Type, /*node*/ any> = new Map();
|
||||||
|
|
||||||
resolve(component: Type): View {
|
resolve(component: Type): ViewMetadata {
|
||||||
var view = this._cache.get(component);
|
var view = this._cache.get(component);
|
||||||
|
|
||||||
if (isBlank(view)) {
|
if (isBlank(view)) {
|
||||||
|
@ -22,11 +22,11 @@ export class ViewResolver {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
_resolve(component: Type): View {
|
_resolve(component: Type): ViewMetadata {
|
||||||
var annotations = reflector.annotations(component);
|
var annotations = reflector.annotations(component);
|
||||||
for (var i = 0; i < annotations.length; i++) {
|
for (var i = 0; i < annotations.length; i++) {
|
||||||
var annotation = annotations[i];
|
var annotation = annotations[i];
|
||||||
if (annotation instanceof View) {
|
if (annotation instanceof ViewMetadata) {
|
||||||
return annotation;
|
return annotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -1,30 +1,57 @@
|
||||||
import {
|
/**
|
||||||
ComponentAnnotation,
|
* This indirection is needed to free up Component, etc symbols in the public API
|
||||||
DirectiveAnnotation,
|
* to be used by the decorator versions of these annotations.
|
||||||
PipeAnnotation,
|
*/
|
||||||
|
|
||||||
|
export {
|
||||||
|
QueryMetadata,
|
||||||
|
ViewQueryMetadata,
|
||||||
|
AttributeMetadata,
|
||||||
|
} from './metadata/di';
|
||||||
|
|
||||||
|
export {
|
||||||
|
ComponentMetadata,
|
||||||
|
DirectiveMetadata,
|
||||||
|
PipeMetadata,
|
||||||
LifecycleEvent
|
LifecycleEvent
|
||||||
} from './annotations';
|
} from './metadata/directives';
|
||||||
import {ViewAnnotation} from './view';
|
|
||||||
import {AttributeAnnotation, QueryAnnotation, ViewQueryAnnotation} from './di';
|
export {ViewMetadata, ViewEncapsulation} from './metadata/view';
|
||||||
import {makeDecorator, makeParamDecorator, TypeDecorator, Class} from '../../util/decorators';
|
|
||||||
|
|
||||||
|
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 {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}.
|
* See {@link DirectiveFactory}.
|
||||||
*/
|
*/
|
||||||
export interface DirectiveDecorator extends TypeDecorator {}
|
export interface DirectiveDecorator extends TypeDecorator {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for the {@link Component} decorator function.
|
* Interface for the {@link ComponentMetadata} decorator function.
|
||||||
*
|
*
|
||||||
* See {@link ComponentFactory}.
|
* See {@link ComponentFactory}.
|
||||||
*/
|
*/
|
||||||
export interface ComponentDecorator extends TypeDecorator {
|
export interface ComponentDecorator extends TypeDecorator {
|
||||||
/**
|
/**
|
||||||
* Chain {@link View} annotation.
|
* Chain {@link ViewMetadata} annotation.
|
||||||
*/
|
*/
|
||||||
View(obj: {
|
View(obj: {
|
||||||
templateUrl?: string,
|
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}.
|
* See {@link ViewFactory}.
|
||||||
*/
|
*/
|
||||||
export interface ViewDecorator extends TypeDecorator {
|
export interface ViewDecorator extends TypeDecorator {
|
||||||
/**
|
/**
|
||||||
* Chain {@link View} annotation.
|
* Chain {@link ViewMetadata} annotation.
|
||||||
*/
|
*/
|
||||||
View(obj: {
|
View(obj: {
|
||||||
templateUrl?: string,
|
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
|
* ## Example as TypeScript Decorator
|
||||||
*
|
*
|
||||||
|
@ -107,7 +134,7 @@ export interface DirectiveFactory {
|
||||||
selector?: string, properties?: List<string>, events?: List<string>,
|
selector?: string, properties?: List<string>, events?: List<string>,
|
||||||
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>,
|
host?: StringMap<string, string>, lifecycle?: List<LifecycleEvent>, bindings?: List<any>,
|
||||||
exportAs?: string, compileChildren?: boolean;
|
exportAs?: string, compileChildren?: boolean;
|
||||||
}): DirectiveAnnotation;
|
}): DirectiveMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +204,7 @@ export interface ComponentFactory {
|
||||||
compileChildren?: boolean,
|
compileChildren?: boolean,
|
||||||
viewBindings?: List<any>,
|
viewBindings?: List<any>,
|
||||||
changeDetection?: string,
|
changeDetection?: string,
|
||||||
}): ComponentAnnotation;
|
}): ComponentMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -239,11 +266,11 @@ export interface ViewFactory {
|
||||||
encapsulation?: ViewEncapsulation,
|
encapsulation?: ViewEncapsulation,
|
||||||
styles?: List<string>,
|
styles?: List<string>,
|
||||||
styleUrls?: 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
|
* ## Example as TypeScript Decorator
|
||||||
*
|
*
|
||||||
|
@ -290,11 +317,11 @@ export interface ViewFactory {
|
||||||
*/
|
*/
|
||||||
export interface AttributeFactory {
|
export interface AttributeFactory {
|
||||||
(name: string): TypeDecorator;
|
(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
|
* ## Example as TypeScript Decorator
|
||||||
*
|
*
|
||||||
|
@ -341,11 +368,11 @@ export interface AttributeFactory {
|
||||||
*/
|
*/
|
||||||
export interface QueryFactory {
|
export interface QueryFactory {
|
||||||
(selector: Type | string, {descendants}?: {descendants?: boolean}): ParameterDecorator;
|
(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
|
* ## Example as TypeScript Decorator
|
||||||
*
|
*
|
||||||
|
@ -370,38 +397,38 @@ export interface PipeFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Component} factory function.
|
* {@link ComponentMetadata} factory function.
|
||||||
*/
|
*/
|
||||||
export var Component: ComponentFactory =
|
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 =
|
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);
|
|
@ -29,7 +29,7 @@ import {resolveForwardRef} from 'angular2/di';
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@CONST()
|
@CONST()
|
||||||
export class Attribute extends DependencyMetadata {
|
export class AttributeMetadata extends DependencyMetadata {
|
||||||
constructor(public attributeName: string) { super(); }
|
constructor(public attributeName: string) { super(); }
|
||||||
|
|
||||||
get token() {
|
get token() {
|
||||||
|
@ -49,7 +49,7 @@ export class Attribute extends DependencyMetadata {
|
||||||
* See {@link QueryList} for usage and example.
|
* See {@link QueryList} for usage and example.
|
||||||
*/
|
*/
|
||||||
@CONST()
|
@CONST()
|
||||||
export class Query extends DependencyMetadata {
|
export class QueryMetadata extends DependencyMetadata {
|
||||||
descendants: boolean;
|
descendants: boolean;
|
||||||
constructor(private _selector: Type | string,
|
constructor(private _selector: Type | string,
|
||||||
{descendants = false}: {descendants?: boolean} = {}) {
|
{descendants = false}: {descendants?: boolean} = {}) {
|
||||||
|
@ -74,7 +74,7 @@ export class Query extends DependencyMetadata {
|
||||||
* See {@link QueryList} for usage and example.
|
* See {@link QueryList} for usage and example.
|
||||||
*/
|
*/
|
||||||
@CONST()
|
@CONST()
|
||||||
export class ViewQuery extends Query {
|
export class ViewQueryMetadata extends QueryMetadata {
|
||||||
constructor(_selector: Type | string, {descendants = false}: {descendants?: boolean} = {}) {
|
constructor(_selector: Type | string, {descendants = false}: {descendants?: boolean} = {}) {
|
||||||
super(_selector, {descendants: descendants});
|
super(_selector, {descendants: descendants});
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ import {DEFAULT} from 'angular2/change_detection';
|
||||||
/**
|
/**
|
||||||
* Directives allow you to attach behavior to elements in the DOM.
|
* 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
|
* A directive consists of a single directive annotation and a controller class. When the
|
||||||
* directive's `selector` matches
|
* directive's `selector` matches
|
||||||
|
@ -39,7 +39,7 @@ import {DEFAULT} from 'angular2/change_detection';
|
||||||
* current `ElementInjector` resolves the constructor dependencies for each directive.
|
* 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
|
* 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
|
* 1. Dependencies on the current element
|
||||||
* 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary
|
* 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:
|
* To inject element-specific special objects, declare the constructor parameter as:
|
||||||
* - `element: ElementRef` to obtain a reference to logical element in the view.
|
* - `element: ElementRef` to obtain a reference to logical element in the view.
|
||||||
* - `viewContainer: ViewContainerRef` to control child template instantiation, for
|
* - `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.
|
* - `bindingPropagation: BindingPropagation` to control change detection in a more granular way.
|
||||||
*
|
*
|
||||||
* ## Example
|
* ## Example
|
||||||
|
@ -288,7 +288,7 @@ import {DEFAULT} from 'angular2/change_detection';
|
||||||
* location in the current view
|
* location in the current view
|
||||||
* where these actions are performed.
|
* 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
|
* `<template>` element. Thus a
|
||||||
* directive in a child view cannot inject the directive that created it.
|
* 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.
|
* view occurs on the second `<li></li>` which is a sibling to the `<template>` element.
|
||||||
*/
|
*/
|
||||||
@CONST()
|
@CONST()
|
||||||
export class Directive extends InjectableMetadata {
|
export class DirectiveMetadata extends InjectableMetadata {
|
||||||
/**
|
/**
|
||||||
* The CSS selector that triggers the instantiation of a directive.
|
* 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.
|
* - `directiveProperty` specifies the component property where the value is written.
|
||||||
* - `bindingProperty` specifies the DOM property where the value is read from.
|
* - `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
|
* transformation and structural change detection of the value. These pipes will be evaluated in
|
||||||
* the context of this component.
|
* 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.
|
* 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
|
* ## Example
|
||||||
*
|
*
|
||||||
|
@ -790,7 +790,7 @@ export class Directive extends InjectableMetadata {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@CONST()
|
@CONST()
|
||||||
export class Component extends Directive {
|
export class ComponentMetadata extends DirectiveMetadata {
|
||||||
/**
|
/**
|
||||||
* Defines the used change detection strategy.
|
* Defines the used change detection strategy.
|
||||||
*
|
*
|
||||||
|
@ -884,7 +884,7 @@ export class Component extends Directive {
|
||||||
*/
|
*/
|
||||||
export enum LifecycleEvent {
|
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
|
* ## Example
|
||||||
*
|
*
|
||||||
|
@ -1022,7 +1022,7 @@ export enum LifecycleEvent {
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@CONST()
|
@CONST()
|
||||||
export class Pipe extends InjectableMetadata {
|
export class PipeMetadata extends InjectableMetadata {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
constructor({name}: {name: string}) {
|
constructor({name}: {name: string}) {
|
|
@ -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
|
* 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.
|
* 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
|
* ## Example
|
||||||
*
|
*
|
||||||
|
@ -35,7 +35,7 @@ export {ViewEncapsulation} from 'angular2/src/render/api';
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@CONST()
|
@CONST()
|
||||||
export class View {
|
export class ViewMetadata {
|
||||||
/**
|
/**
|
||||||
* Specifies a template URL for an angular component.
|
* Specifies a template URL for an angular component.
|
||||||
*
|
*
|
|
@ -1,13 +1,13 @@
|
||||||
import {Type} from 'angular2/src/facade/lang';
|
import {Type} from 'angular2/src/facade/lang';
|
||||||
import {Key, Dependency, ResolvedBinding, Binding} from 'angular2/di';
|
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 {
|
export class PipeBinding extends ResolvedBinding {
|
||||||
constructor(public name: string, key: Key, factory: Function, dependencies: Dependency[]) {
|
constructor(public name: string, key: Key, factory: Function, dependencies: Dependency[]) {
|
||||||
super(key, factory, dependencies);
|
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 binding = new Binding(type, {toClass: type});
|
||||||
var rb = binding.resolve();
|
var rb = binding.resolve();
|
||||||
return new PipeBinding(metadata.name, rb.key, rb.factory, rb.dependencies);
|
return new PipeBinding(metadata.name, rb.key, rb.factory, rb.dependencies);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as cd from 'angular2/src/change_detection/pipes';
|
||||||
|
|
||||||
export class ProtoPipes {
|
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> = {};
|
config: StringMap<string, PipeBinding> = {};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {isPresent, isString, StringWrapper, isBlank} from 'angular2/src/facade/lang';
|
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 {ElementRef} from 'angular2/core';
|
||||||
import {Renderer} from 'angular2/src/render/api';
|
import {Renderer} from 'angular2/src/render/api';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Directive, LifecycleEvent} from 'angular2/annotations';
|
import {Directive, LifecycleEvent} from 'angular2/metadata';
|
||||||
import {ViewContainerRef, ViewRef, TemplateRef} from 'angular2/core';
|
import {ViewContainerRef, ViewRef, TemplateRef} from 'angular2/core';
|
||||||
import {ChangeDetectorRef, IterableDiffer, IterableDiffers} from 'angular2/change_detection';
|
import {ChangeDetectorRef, IterableDiffer, IterableDiffers} from 'angular2/change_detection';
|
||||||
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Directive} from 'angular2/annotations';
|
import {Directive} from 'angular2/metadata';
|
||||||
import {ViewContainerRef, TemplateRef} from 'angular2/core';
|
import {ViewContainerRef, TemplateRef} from 'angular2/core';
|
||||||
import {isBlank} from 'angular2/src/facade/lang';
|
import {isBlank} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
|
|
|
@ -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
|
* The `NgNonBindable` directive tells Angular not to compile or bind the contents of the current
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Directive, LifecycleEvent} from 'angular2/annotations';
|
import {Directive, LifecycleEvent} from 'angular2/metadata';
|
||||||
import {ElementRef} from 'angular2/core';
|
import {ElementRef} from 'angular2/core';
|
||||||
import {KeyValueDiffer, KeyValueDiffers} from 'angular2/change_detection';
|
import {KeyValueDiffer, KeyValueDiffers} from 'angular2/change_detection';
|
||||||
import {isPresent, isBlank, print} from 'angular2/src/facade/lang';
|
import {isPresent, isBlank, print} from 'angular2/src/facade/lang';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Directive} from 'angular2/annotations';
|
import {Directive} from 'angular2/metadata';
|
||||||
import {Host} from 'angular2/di';
|
import {Host} from 'angular2/di';
|
||||||
import {ViewContainerRef, TemplateRef} from 'angular2/core';
|
import {ViewContainerRef, TemplateRef} from 'angular2/core';
|
||||||
import {isPresent, isBlank, normalizeBlank, CONST_EXPR} from 'angular2/src/facade/lang';
|
import {isPresent, isBlank, normalizeBlank, CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {Renderer} from 'angular2/render';
|
import {Renderer} from 'angular2/render';
|
||||||
import {Directive} from 'angular2/annotations';
|
import {Directive} from 'angular2/metadata';
|
||||||
import {ElementRef} from 'angular2/core';
|
import {ElementRef} from 'angular2/core';
|
||||||
import {Self} from 'angular2/di';
|
import {Self} from 'angular2/di';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import {Renderer} from 'angular2/render';
|
import {Renderer} from 'angular2/render';
|
||||||
import {Directive} from 'angular2/annotations';
|
import {Directive} from 'angular2/metadata';
|
||||||
import {ElementRef} from 'angular2/core';
|
import {ElementRef} from 'angular2/core';
|
||||||
import {Self} from 'angular2/di';
|
import {Self} from 'angular2/di';
|
||||||
import {NgControl} from './ng_control';
|
import {NgControl} from './ng_control';
|
||||||
|
|
|
@ -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 {Inject, Host, SkipSelf, forwardRef, Binding} from 'angular2/di';
|
||||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
import {List, StringMap} from 'angular2/src/facade/collection';
|
import {List, StringMap} from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
import {QueryList} from 'angular2/core';
|
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 {forwardRef, Host, SkipSelf, Binding, Inject} from 'angular2/di';
|
||||||
|
|
||||||
import {ControlContainer} from './control_container';
|
import {ControlContainer} from './control_container';
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
} from 'angular2/src/facade/async';
|
} from 'angular2/src/facade/async';
|
||||||
import {StringMapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
|
import {StringMapWrapper, List, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/facade/lang';
|
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 {forwardRef, Binding} from 'angular2/di';
|
||||||
import {NgControl} from './ng_control';
|
import {NgControl} from './ng_control';
|
||||||
import {Form} from './form_interface';
|
import {Form} from './form_interface';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
|
|
||||||
import {QueryList} from 'angular2/core';
|
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 {forwardRef, Binding} from 'angular2/di';
|
||||||
|
|
||||||
import {NgControl} from './ng_control';
|
import {NgControl} from './ng_control';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async';
|
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 {forwardRef, Binding} from 'angular2/di';
|
||||||
import {NgControl} from './ng_control';
|
import {NgControl} from './ng_control';
|
||||||
import {NgControlGroup} from './ng_control_group';
|
import {NgControlGroup} from './ng_control_group';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
import {EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
|
|
||||||
import {QueryList} from 'angular2/core';
|
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 {forwardRef, Binding} from 'angular2/di';
|
||||||
|
|
||||||
import {NgControl} from './ng_control';
|
import {NgControl} from './ng_control';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {Renderer} from 'angular2/render';
|
import {Renderer} from 'angular2/render';
|
||||||
import {ElementRef, QueryList} from 'angular2/core';
|
import {ElementRef, QueryList} from 'angular2/core';
|
||||||
import {Self} from 'angular2/di';
|
import {Self} from 'angular2/di';
|
||||||
import {Query, Directive} from 'angular2/annotations';
|
import {Query, Directive} from 'angular2/metadata';
|
||||||
|
|
||||||
import {NgControl} from './ng_control';
|
import {NgControl} from './ng_control';
|
||||||
import {ControlValueAccessor} from './control_value_accessor';
|
import {ControlValueAccessor} from './control_value_accessor';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {forwardRef, Binding} from 'angular2/di';
|
import {forwardRef, Binding} from 'angular2/di';
|
||||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||||
import {Directive} from 'angular2/annotations';
|
import {Directive} from 'angular2/metadata';
|
||||||
import {Validators} from '../validators';
|
import {Validators} from '../validators';
|
||||||
|
|
||||||
export class NgValidator {
|
export class NgValidator {
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {Type, isPresent, BaseException, stringify, isBlank} from 'angular2/src/facade/lang';
|
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';
|
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
|
||||||
|
|
||||||
export class MockViewResolver extends ViewResolver {
|
export class MockViewResolver extends ViewResolver {
|
||||||
_views: Map<Type, View> = new Map();
|
_views: Map<Type, ViewMetadata> = new Map();
|
||||||
_inlineTemplates: Map<Type, string> = 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();
|
_directiveOverrides: Map<Type, Map<Type, Type>> = new Map();
|
||||||
|
|
||||||
constructor() { super(); }
|
constructor() { super(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides the {@link View} for a component.
|
* Overrides the {@link ViewMetadata} for a component.
|
||||||
*
|
*
|
||||||
* @param {Type} component
|
* @param {Type} component
|
||||||
* @param {ViewDefinition} view
|
* @param {ViewDefinition} view
|
||||||
*/
|
*/
|
||||||
setView(component: Type, view: View): void {
|
setView(component: Type, view: ViewMetadata): void {
|
||||||
this._checkOverrideable(component);
|
this._checkOverrideable(component);
|
||||||
this._views.set(component, view);
|
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} component
|
||||||
* @param {Type} from
|
* @param {Type} from
|
||||||
|
@ -55,8 +55,8 @@ export class MockViewResolver extends ViewResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link View} for a component:
|
* Returns the {@link ViewMetadata} for a component:
|
||||||
* - Set the {@link View} to the overridden view when it exists or fallback to the default
|
* - Set the {@link ViewMetadata} to the overridden view when it exists or fallback to the default
|
||||||
* `ViewResolver`,
|
* `ViewResolver`,
|
||||||
* see `setView`.
|
* see `setView`.
|
||||||
* - Override the directives, see `overrideViewDirective`.
|
* - Override the directives, see `overrideViewDirective`.
|
||||||
|
@ -65,7 +65,7 @@ export class MockViewResolver extends ViewResolver {
|
||||||
* @param component
|
* @param component
|
||||||
* @returns {ViewDefinition}
|
* @returns {ViewDefinition}
|
||||||
*/
|
*/
|
||||||
resolve(component: Type): View {
|
resolve(component: Type): ViewMetadata {
|
||||||
var view = this._viewCache.get(component);
|
var view = this._viewCache.get(component);
|
||||||
if (isPresent(view)) return view;
|
if (isPresent(view)) return view;
|
||||||
|
|
||||||
|
@ -87,13 +87,14 @@ export class MockViewResolver extends ViewResolver {
|
||||||
}
|
}
|
||||||
directives[srcIndex] = to;
|
directives[srcIndex] = to;
|
||||||
});
|
});
|
||||||
view = new View(
|
view = new ViewMetadata(
|
||||||
{template: view.template, templateUrl: view.templateUrl, directives: directives});
|
{template: view.template, templateUrl: view.templateUrl, directives: directives});
|
||||||
}
|
}
|
||||||
|
|
||||||
var inlineTemplate = this._inlineTemplates.get(component);
|
var inlineTemplate = this._inlineTemplates.get(component);
|
||||||
if (isPresent(inlineTemplate)) {
|
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);
|
this._viewCache.set(component, view);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {PipeTransform, PipeOnDestroy, WrappedValue} from 'angular2/change_detect
|
||||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||||
import {ChangeDetectorRef} from 'angular2/change_detection';
|
import {ChangeDetectorRef} from 'angular2/change_detection';
|
||||||
|
|
||||||
import {Pipe} from 'angular2/src/core/annotations/decorators';
|
import {Pipe} from '../core/metadata';
|
||||||
|
|
||||||
|
|
||||||
class ObservableStrategy {
|
class ObservableStrategy {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {StringMapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
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.
|
// TODO: move to a global configable location along with other i18n components.
|
||||||
var defaultLocale: string = 'en-US';
|
var defaultLocale: string = 'en-US';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Injectable} from 'angular2/di';
|
||||||
|
|
||||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
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.
|
* Implements json transforms to any object.
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {Injectable} from 'angular2/di';
|
||||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
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
|
* Creates a new List or String containing only a prefix/suffix of the
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
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.
|
* Implements lowercase transforms to text.
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
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 defaultLocale: string = 'en-US';
|
||||||
var _re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
|
var _re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {Injectable} from 'angular2/di';
|
||||||
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
import {PipeTransform, WrappedValue} from 'angular2/change_detection';
|
||||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
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.
|
* Implements uppercase transforms to text.
|
||||||
|
|
|
@ -36,7 +36,7 @@ export class ElementPropertyBinding {
|
||||||
public property: string, public unit: string = null) {}
|
public property: string, public unit: string = null) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ElementBinder {
|
export class RenderElementBinder {
|
||||||
index: number;
|
index: number;
|
||||||
parentIndex: number;
|
parentIndex: number;
|
||||||
distanceToParent: number;
|
distanceToParent: number;
|
||||||
|
@ -110,7 +110,7 @@ export enum ViewType {
|
||||||
|
|
||||||
export class ProtoViewDto {
|
export class ProtoViewDto {
|
||||||
render: RenderProtoViewRef;
|
render: RenderProtoViewRef;
|
||||||
elementBinders: List<ElementBinder>;
|
elementBinders: List<RenderElementBinder>;
|
||||||
variableBindings: Map<string, string>;
|
variableBindings: Map<string, string>;
|
||||||
type: ViewType;
|
type: ViewType;
|
||||||
textBindings: List<ASTWithSource>;
|
textBindings: List<ASTWithSource>;
|
||||||
|
@ -119,7 +119,7 @@ export class ProtoViewDto {
|
||||||
constructor({render, elementBinders, variableBindings, type, textBindings,
|
constructor({render, elementBinders, variableBindings, type, textBindings,
|
||||||
transitiveNgContentCount}: {
|
transitiveNgContentCount}: {
|
||||||
render?: RenderProtoViewRef,
|
render?: RenderProtoViewRef,
|
||||||
elementBinders?: List<ElementBinder>,
|
elementBinders?: List<RenderElementBinder>,
|
||||||
variableBindings?: Map<string, string>,
|
variableBindings?: Map<string, string>,
|
||||||
type?: ViewType,
|
type?: ViewType,
|
||||||
textBindings?: List<ASTWithSource>,
|
textBindings?: List<ASTWithSource>,
|
||||||
|
@ -134,7 +134,7 @@ export class ProtoViewDto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DirectiveMetadata {
|
export class RenderDirectiveMetadata {
|
||||||
static get DIRECTIVE_TYPE() { return 0; }
|
static get DIRECTIVE_TYPE() { return 0; }
|
||||||
static get COMPONENT_TYPE() { return 1; }
|
static get COMPONENT_TYPE() { return 1; }
|
||||||
id: any;
|
id: any;
|
||||||
|
@ -220,7 +220,7 @@ export class DirectiveMetadata {
|
||||||
callOnAllChangesDone?: boolean,
|
callOnAllChangesDone?: boolean,
|
||||||
changeDetection?: string,
|
changeDetection?: string,
|
||||||
exportAs?: string
|
exportAs?: string
|
||||||
}): DirectiveMetadata {
|
}): RenderDirectiveMetadata {
|
||||||
let hostListeners = new Map();
|
let hostListeners = new Map();
|
||||||
let hostProperties = new Map();
|
let hostProperties = new Map();
|
||||||
let hostAttributes = new Map();
|
let hostAttributes = new Map();
|
||||||
|
@ -228,7 +228,7 @@ export class DirectiveMetadata {
|
||||||
|
|
||||||
if (isPresent(host)) {
|
if (isPresent(host)) {
|
||||||
MapWrapper.forEach(host, (value: string, key: string) => {
|
MapWrapper.forEach(host, (value: string, key: string) => {
|
||||||
var matches = RegExpWrapper.firstMatch(DirectiveMetadata._hostRegExp, key);
|
var matches = RegExpWrapper.firstMatch(RenderDirectiveMetadata._hostRegExp, key);
|
||||||
if (isBlank(matches)) {
|
if (isBlank(matches)) {
|
||||||
hostAttributes.set(key, value);
|
hostAttributes.set(key, value);
|
||||||
} else if (isPresent(matches[1])) {
|
} else if (isPresent(matches[1])) {
|
||||||
|
@ -241,7 +241,7 @@ export class DirectiveMetadata {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DirectiveMetadata({
|
return new RenderDirectiveMetadata({
|
||||||
id: id,
|
id: id,
|
||||||
selector: selector,
|
selector: selector,
|
||||||
compileChildren: compileChildren,
|
compileChildren: compileChildren,
|
||||||
|
@ -296,7 +296,7 @@ export class ViewDefinition {
|
||||||
componentId: string;
|
componentId: string;
|
||||||
templateAbsUrl: string;
|
templateAbsUrl: string;
|
||||||
template: string;
|
template: string;
|
||||||
directives: List<DirectiveMetadata>;
|
directives: List<RenderDirectiveMetadata>;
|
||||||
styleAbsUrls: List<string>;
|
styleAbsUrls: List<string>;
|
||||||
styles: List<string>;
|
styles: List<string>;
|
||||||
encapsulation: ViewEncapsulation;
|
encapsulation: ViewEncapsulation;
|
||||||
|
@ -308,7 +308,7 @@ export class ViewDefinition {
|
||||||
template?: string,
|
template?: string,
|
||||||
styleAbsUrls?: List<string>,
|
styleAbsUrls?: List<string>,
|
||||||
styles?: List<string>,
|
styles?: List<string>,
|
||||||
directives?: List<DirectiveMetadata>,
|
directives?: List<RenderDirectiveMetadata>,
|
||||||
encapsulation?: ViewEncapsulation
|
encapsulation?: ViewEncapsulation
|
||||||
} = {}) {
|
} = {}) {
|
||||||
this.componentId = componentId;
|
this.componentId = componentId;
|
||||||
|
@ -348,7 +348,7 @@ export class RenderCompiler {
|
||||||
/**
|
/**
|
||||||
* Creats a ProtoViewDto that contains a single nested component with the given componentId.
|
* 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
|
* Compiles a single DomProtoView. Non recursive so that
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
ViewDefinition,
|
ViewDefinition,
|
||||||
ProtoViewDto,
|
ProtoViewDto,
|
||||||
ViewType,
|
ViewType,
|
||||||
DirectiveMetadata,
|
RenderDirectiveMetadata,
|
||||||
RenderCompiler,
|
RenderCompiler,
|
||||||
RenderProtoViewRef,
|
RenderProtoViewRef,
|
||||||
RenderProtoViewMergeMapping,
|
RenderProtoViewMergeMapping,
|
||||||
|
@ -50,7 +50,7 @@ export class DomCompiler extends RenderCompiler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
compileHost(directiveMetadata: DirectiveMetadata): Promise<ProtoViewDto> {
|
compileHost(directiveMetadata: RenderDirectiveMetadata): Promise<ProtoViewDto> {
|
||||||
let hostViewDef = new ViewDefinition({
|
let hostViewDef = new ViewDefinition({
|
||||||
componentId: directiveMetadata.id,
|
componentId: directiveMetadata.id,
|
||||||
templateAbsUrl: null, template: null,
|
templateAbsUrl: null, template: null,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {CompileStep} from './compile_step';
|
||||||
import {CompileElement} from './compile_element';
|
import {CompileElement} from './compile_element';
|
||||||
import {CompileControl} from './compile_control';
|
import {CompileControl} from './compile_control';
|
||||||
|
|
||||||
import {DirectiveMetadata} from '../../api';
|
import {RenderDirectiveMetadata} from '../../api';
|
||||||
import {dashCaseToCamelCase, camelCaseToDashCase, EVENT_TARGET_SEPARATOR} from '../util';
|
import {dashCaseToCamelCase, camelCaseToDashCase, EVENT_TARGET_SEPARATOR} from '../util';
|
||||||
import {DirectiveBuilder, ElementBinderBuilder} from '../view/proto_view_builder';
|
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 {
|
export class DirectiveParser implements CompileStep {
|
||||||
_selectorMatcher: SelectorMatcher = new SelectorMatcher();
|
_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++) {
|
for (var i = 0; i < _directives.length; i++) {
|
||||||
var directive = _directives[i];
|
var directive = _directives[i];
|
||||||
var selector = CssSelector.parse(directive.selector);
|
var selector = CssSelector.parse(directive.selector);
|
||||||
|
@ -48,7 +48,7 @@ export class DirectiveParser implements CompileStep {
|
||||||
var directive = this._directives[directiveIndex];
|
var directive = this._directives[directiveIndex];
|
||||||
|
|
||||||
elementBinder = current.bindElement();
|
elementBinder = current.bindElement();
|
||||||
if (directive.type === DirectiveMetadata.COMPONENT_TYPE) {
|
if (directive.type === RenderDirectiveMetadata.COMPONENT_TYPE) {
|
||||||
this._ensureHasOnlyOneComponent(elementBinder, current.elementDescription);
|
this._ensureHasOnlyOneComponent(elementBinder, current.elementDescription);
|
||||||
|
|
||||||
// components need to go first, so it is easier to locate them in the result.
|
// components need to go first, so it is easier to locate them in the result.
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||||
import {isPresent, isArray} from 'angular2/src/facade/lang';
|
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,
|
* Converts a [DirectiveMetadata] to a map representation. This creates a copy,
|
||||||
* that is, subsequent changes to `meta` will not be mirrored in the map.
|
* 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([
|
return MapWrapper.createFromPairs([
|
||||||
['id', meta.id],
|
['id', meta.id],
|
||||||
['selector', meta.selector],
|
['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
|
* [DirectiveMetadata] object. This creates a copy, that is, subsequent changes
|
||||||
* to `map` will not be mirrored in the [DirectiveMetadata] object.
|
* to `map` will not be mirrored in the [DirectiveMetadata] object.
|
||||||
*/
|
*/
|
||||||
export function directiveMetadataFromMap(map: Map<string, any>): DirectiveMetadata {
|
export function directiveMetadataFromMap(map: Map<string, any>): RenderDirectiveMetadata {
|
||||||
return new DirectiveMetadata({
|
return new RenderDirectiveMetadata({
|
||||||
id:<string>map.get('id'),
|
id:<string>map.get('id'),
|
||||||
selector:<string>map.get('selector'),
|
selector:<string>map.get('selector'),
|
||||||
compileChildren:<boolean>map.get('compileChildren'),
|
compileChildren:<boolean>map.get('compileChildren'),
|
||||||
|
|
|
@ -23,7 +23,16 @@ import {DomElementBinder, Event, HostAction} from './element_binder';
|
||||||
import {ElementSchemaRegistry} from '../schema/element_schema_registry';
|
import {ElementSchemaRegistry} from '../schema/element_schema_registry';
|
||||||
import {TemplateCloner} from '../template_cloner';
|
import {TemplateCloner} from '../template_cloner';
|
||||||
|
|
||||||
import * as api from '../../api';
|
import {
|
||||||
|
ViewType,
|
||||||
|
ViewEncapsulation,
|
||||||
|
ProtoViewDto,
|
||||||
|
DirectiveBinder,
|
||||||
|
RenderElementBinder,
|
||||||
|
EventBinding,
|
||||||
|
ElementPropertyBinding,
|
||||||
|
PropertyBindingType
|
||||||
|
} from '../../api';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NG_BINDING_CLASS,
|
NG_BINDING_CLASS,
|
||||||
|
@ -39,8 +48,8 @@ export class ProtoViewBuilder {
|
||||||
ngContentCount: number = 0;
|
ngContentCount: number = 0;
|
||||||
hostAttributes: Map<string, string> = new Map();
|
hostAttributes: Map<string, string> = new Map();
|
||||||
|
|
||||||
constructor(public rootElement, public type: api.ViewType,
|
constructor(public rootElement, public type: ViewType,
|
||||||
public viewEncapsulation: api.ViewEncapsulation) {}
|
public viewEncapsulation: ViewEncapsulation) {}
|
||||||
|
|
||||||
bindElement(element: HTMLElement, description: string = null): ElementBinderBuilder {
|
bindElement(element: HTMLElement, description: string = null): ElementBinderBuilder {
|
||||||
var builder = new ElementBinderBuilder(this.elements.length, element, description);
|
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); }
|
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 domElementBinders = [];
|
||||||
|
|
||||||
var apiElementBinders = [];
|
var apiElementBinders = [];
|
||||||
|
@ -89,7 +98,7 @@ export class ProtoViewBuilder {
|
||||||
ebb.eventBuilder.merge(dbb.eventBuilder);
|
ebb.eventBuilder.merge(dbb.eventBuilder);
|
||||||
ListWrapper.forEach(dbb.templatePropertyNames,
|
ListWrapper.forEach(dbb.templatePropertyNames,
|
||||||
(name) => directiveTemplatePropertyNames.add(name));
|
(name) => directiveTemplatePropertyNames.add(name));
|
||||||
return new api.DirectiveBinder({
|
return new DirectiveBinder({
|
||||||
directiveIndex: dbb.directiveIndex,
|
directiveIndex: dbb.directiveIndex,
|
||||||
propertyBindings: dbb.propertyBindings,
|
propertyBindings: dbb.propertyBindings,
|
||||||
eventBindings: dbb.eventBindings,
|
eventBindings: dbb.eventBindings,
|
||||||
|
@ -109,7 +118,7 @@ export class ProtoViewBuilder {
|
||||||
textNodeExpressions.push(expression);
|
textNodeExpressions.push(expression);
|
||||||
textNodeIndices.push(nodeIndex);
|
textNodeIndices.push(nodeIndex);
|
||||||
});
|
});
|
||||||
apiElementBinders.push(new api.ElementBinder({
|
apiElementBinders.push(new RenderElementBinder({
|
||||||
index: ebb.index,
|
index: ebb.index,
|
||||||
parentIndex: parentIndex,
|
parentIndex: parentIndex,
|
||||||
distanceToParent: ebb.distanceToParent,
|
distanceToParent: ebb.distanceToParent,
|
||||||
|
@ -132,7 +141,7 @@ export class ProtoViewBuilder {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
var rootNodeCount = DOM.childNodes(DOM.content(this.rootElement)).length;
|
var rootNodeCount = DOM.childNodes(DOM.content(this.rootElement)).length;
|
||||||
return new api.ProtoViewDto({
|
return new ProtoViewDto({
|
||||||
render: new DomProtoViewRef(DomProtoView.create(
|
render: new DomProtoViewRef(DomProtoView.create(
|
||||||
templateCloner, this.type, this.rootElement, this.viewEncapsulation, [rootNodeCount],
|
templateCloner, this.type, this.rootElement, this.viewEncapsulation, [rootNodeCount],
|
||||||
rootTextNodeIndices, domElementBinders, this.hostAttributes)),
|
rootTextNodeIndices, domElementBinders, this.hostAttributes)),
|
||||||
|
@ -152,7 +161,7 @@ export class ElementBinderBuilder {
|
||||||
nestedProtoView: ProtoViewBuilder = null;
|
nestedProtoView: ProtoViewBuilder = null;
|
||||||
propertyBindings: Map<string, ASTWithSource> = new Map();
|
propertyBindings: Map<string, ASTWithSource> = new Map();
|
||||||
variableBindings: Map<string, string> = new Map();
|
variableBindings: Map<string, string> = new Map();
|
||||||
eventBindings: List<api.EventBinding> = [];
|
eventBindings: List<EventBinding> = [];
|
||||||
eventBuilder: EventBuilder = new EventBuilder();
|
eventBuilder: EventBuilder = new EventBuilder();
|
||||||
textBindings: Map<Node, ASTWithSource> = new Map();
|
textBindings: Map<Node, ASTWithSource> = new Map();
|
||||||
readAttributes: Map<string, string> = 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');
|
throw new BaseException('Only one nested view per element is allowed');
|
||||||
}
|
}
|
||||||
this.nestedProtoView =
|
this.nestedProtoView =
|
||||||
new ProtoViewBuilder(rootElement, api.ViewType.EMBEDDED, api.ViewEncapsulation.NONE);
|
new ProtoViewBuilder(rootElement, ViewType.EMBEDDED, ViewEncapsulation.NONE);
|
||||||
return this.nestedProtoView;
|
return this.nestedProtoView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +239,7 @@ export class DirectiveBuilder {
|
||||||
// property names used in the template
|
// property names used in the template
|
||||||
templatePropertyNames: List<string> = [];
|
templatePropertyNames: List<string> = [];
|
||||||
hostPropertyBindings: Map<string, ASTWithSource> = new Map();
|
hostPropertyBindings: Map<string, ASTWithSource> = new Map();
|
||||||
eventBindings: List<api.EventBinding> = [];
|
eventBindings: List<EventBinding> = [];
|
||||||
eventBuilder: EventBuilder = new EventBuilder();
|
eventBuilder: EventBuilder = new EventBuilder();
|
||||||
|
|
||||||
constructor(public directiveIndex: number) {}
|
constructor(public directiveIndex: number) {}
|
||||||
|
@ -261,14 +270,14 @@ export class EventBuilder extends AstTransformer {
|
||||||
|
|
||||||
constructor() { super(); }
|
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
|
// TODO(tbosch): reenable this when we are parsing element properties
|
||||||
// out of action expressions
|
// out of action expressions
|
||||||
// var adjustedAst = astWithSource.ast.visit(this);
|
// var adjustedAst = astWithSource.ast.visit(this);
|
||||||
var adjustedAst = source.ast;
|
var adjustedAst = source.ast;
|
||||||
var fullName = isPresent(target) ? target + EVENT_TARGET_SEPARATOR + name : name;
|
var fullName = isPresent(target) ? target + EVENT_TARGET_SEPARATOR + name : name;
|
||||||
var result = new api.EventBinding(
|
var result =
|
||||||
fullName, new ASTWithSource(adjustedAst, source.source, source.location));
|
new EventBinding(fullName, new ASTWithSource(adjustedAst, source.source, source.location));
|
||||||
var event = new Event(name, target, fullName);
|
var event = new Event(name, target, fullName);
|
||||||
if (isBlank(target)) {
|
if (isBlank(target)) {
|
||||||
this.localEvents.push(event);
|
this.localEvents.push(event);
|
||||||
|
@ -331,7 +340,7 @@ const STYLE_PREFIX = 'style';
|
||||||
function buildElementPropertyBindings(
|
function buildElementPropertyBindings(
|
||||||
schemaRegistry: ElementSchemaRegistry, protoElement: /*element*/ any, isNgComponent: boolean,
|
schemaRegistry: ElementSchemaRegistry, protoElement: /*element*/ any, isNgComponent: boolean,
|
||||||
bindingsInTemplate: Map<string, ASTWithSource>, directiveTemplatePropertyNames: Set<string>):
|
bindingsInTemplate: Map<string, ASTWithSource>, directiveTemplatePropertyNames: Set<string>):
|
||||||
List<api.ElementPropertyBinding> {
|
List<ElementPropertyBinding> {
|
||||||
var propertyBindings = [];
|
var propertyBindings = [];
|
||||||
|
|
||||||
MapWrapper.forEach(bindingsInTemplate, (ast, propertyNameInTemplate) => {
|
MapWrapper.forEach(bindingsInTemplate, (ast, propertyNameInTemplate) => {
|
||||||
|
@ -361,8 +370,8 @@ function buildElementPropertyBindings(
|
||||||
|
|
||||||
function isValidElementPropertyBinding(schemaRegistry: ElementSchemaRegistry,
|
function isValidElementPropertyBinding(schemaRegistry: ElementSchemaRegistry,
|
||||||
protoElement: /*element*/ any, isNgComponent: boolean,
|
protoElement: /*element*/ any, isNgComponent: boolean,
|
||||||
binding: api.ElementPropertyBinding): boolean {
|
binding: ElementPropertyBinding): boolean {
|
||||||
if (binding.type === api.PropertyBindingType.PROPERTY) {
|
if (binding.type === PropertyBindingType.PROPERTY) {
|
||||||
if (!isNgComponent) {
|
if (!isNgComponent) {
|
||||||
return schemaRegistry.hasProperty(protoElement, binding.property);
|
return schemaRegistry.hasProperty(protoElement, binding.property);
|
||||||
} else {
|
} else {
|
||||||
|
@ -374,19 +383,19 @@ function isValidElementPropertyBinding(schemaRegistry: ElementSchemaRegistry,
|
||||||
}
|
}
|
||||||
|
|
||||||
function createElementPropertyBinding(schemaRegistry: ElementSchemaRegistry, ast: ASTWithSource,
|
function createElementPropertyBinding(schemaRegistry: ElementSchemaRegistry, ast: ASTWithSource,
|
||||||
propertyNameInTemplate: string): api.ElementPropertyBinding {
|
propertyNameInTemplate: string): ElementPropertyBinding {
|
||||||
var parts = StringWrapper.split(propertyNameInTemplate, PROPERTY_PARTS_SEPARATOR);
|
var parts = StringWrapper.split(propertyNameInTemplate, PROPERTY_PARTS_SEPARATOR);
|
||||||
if (parts.length === 1) {
|
if (parts.length === 1) {
|
||||||
var propName = schemaRegistry.getMappedPropName(parts[0]);
|
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) {
|
} 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) {
|
} else if (parts[0] == CLASS_PREFIX) {
|
||||||
return new api.ElementPropertyBinding(api.PropertyBindingType.CLASS, ast,
|
return new ElementPropertyBinding(PropertyBindingType.CLASS, ast,
|
||||||
camelCaseToDashCase(parts[1]));
|
camelCaseToDashCase(parts[1]));
|
||||||
} else if (parts[0] == STYLE_PREFIX) {
|
} else if (parts[0] == STYLE_PREFIX) {
|
||||||
var unit = parts.length > 2 ? parts[2] : null;
|
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 {
|
} else {
|
||||||
throw new BaseException(`Invalid property name ${propertyNameInTemplate}`);
|
throw new BaseException(`Invalid property name ${propertyNameInTemplate}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {List, StringMap, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
import {Router} from './router';
|
import {Router} from './router';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
||||||
import {StringMapWrapper} from 'angular2/src/facade/collection';
|
import {StringMapWrapper} from 'angular2/src/facade/collection';
|
||||||
import {isBlank, isPresent} from 'angular2/src/facade/lang';
|
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 {DynamicComponentLoader, ComponentRef, ElementRef} from 'angular2/core';
|
||||||
import {Injector, bind, Dependency, UNDEFINED} from 'angular2/di';
|
import {Injector, bind, Dependency, UNDEFINED} from 'angular2/di';
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {Type, isPresent, BaseException, isBlank} from 'angular2/src/facade/lang'
|
||||||
import {Promise} from 'angular2/src/facade/async';
|
import {Promise} from 'angular2/src/facade/async';
|
||||||
import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
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 {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
|
||||||
import {AppView} from 'angular2/src/core/compiler/view';
|
import {AppView} from 'angular2/src/core/compiler/view';
|
||||||
|
@ -48,7 +48,7 @@ var _nextRootElementId = 0;
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TestComponentBuilder {
|
export class TestComponentBuilder {
|
||||||
_injector: Injector;
|
_injector: Injector;
|
||||||
_viewOverrides: Map<Type, View>;
|
_viewOverrides: Map<Type, ViewMetadata>;
|
||||||
_directiveOverrides: Map<Type, Map<Type, Type>>;
|
_directiveOverrides: Map<Type, Map<Type, Type>>;
|
||||||
_templateOverrides: Map<Type, string>;
|
_templateOverrides: Map<Type, string>;
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ export class TestComponentBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides only the html of a {@link Component}.
|
* Overrides only the html of a {@link ComponentMetadata}.
|
||||||
* All the other properties of the component's {@link View} are preserved.
|
* All the other properties of the component's {@link ViewMetadata} are preserved.
|
||||||
*
|
*
|
||||||
* @param {Type} component
|
* @param {Type} component
|
||||||
* @param {string} html
|
* @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 {Type} component
|
||||||
* @param {view} View
|
* @param {view} View
|
||||||
*
|
*
|
||||||
* @return {TestComponentBuilder}
|
* @return {TestComponentBuilder}
|
||||||
*/
|
*/
|
||||||
overrideView(componentType: Type, view: View): TestComponentBuilder {
|
overrideView(componentType: Type, view: ViewMetadata): TestComponentBuilder {
|
||||||
var clone = this._clone();
|
var clone = this._clone();
|
||||||
clone._viewOverrides.set(componentType, view);
|
clone._viewOverrides.set(componentType, view);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides the directives from the component {@link View}.
|
* Overrides the directives from the component {@link ViewMetadata}.
|
||||||
*
|
*
|
||||||
* @param {Type} component
|
* @param {Type} component
|
||||||
* @param {Type} from
|
* @param {Type} from
|
||||||
|
|
|
@ -18,16 +18,11 @@ const INJECTABLES = const [
|
||||||
];
|
];
|
||||||
|
|
||||||
const DIRECTIVES = const [
|
const DIRECTIVES = const [
|
||||||
const ClassDescriptor(
|
const ClassDescriptor('Directive', 'package:angular2/src/core/metadatada/directive.dart',
|
||||||
'Directive', 'package:angular2/src/core/annotations/annotations.dart',
|
|
||||||
superClass: 'Injectable'),
|
superClass: 'Injectable'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor('Directive', 'package:angular2/src/core/metadata.dart',
|
||||||
'Directive', 'package:angular2/src/core/annotations/decorators.dart',
|
|
||||||
superClass: 'Injectable'),
|
superClass: 'Injectable'),
|
||||||
const ClassDescriptor('Directive',
|
const ClassDescriptor('Directive', 'package:angular2/metadata.dart',
|
||||||
'package:angular2/src/core/annotations_impl/annotations.dart',
|
|
||||||
superClass: 'Injectable'),
|
|
||||||
const ClassDescriptor('Directive', 'package:angular2/annotations.dart',
|
|
||||||
superClass: 'Injectable'),
|
superClass: 'Injectable'),
|
||||||
const ClassDescriptor('Directive', 'package:angular2/angular2.dart',
|
const ClassDescriptor('Directive', 'package:angular2/angular2.dart',
|
||||||
superClass: 'Injectable'),
|
superClass: 'Injectable'),
|
||||||
|
@ -38,34 +33,26 @@ const DIRECTIVES = const [
|
||||||
];
|
];
|
||||||
|
|
||||||
const COMPONENTS = const [
|
const COMPONENTS = const [
|
||||||
const ClassDescriptor(
|
const ClassDescriptor('Component', 'package:angular2/src/core/metadata/directive.dart',
|
||||||
'Component', 'package:angular2/src/core/annotations/annotations.dart',
|
|
||||||
superClass: 'Directive'),
|
superClass: 'Directive'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor('Component', 'package:angular2/src/core/metadata.dart',
|
||||||
'Component', 'package:angular2/src/core/annotations/decorators.dart',
|
|
||||||
superClass: 'Directive'),
|
superClass: 'Directive'),
|
||||||
const ClassDescriptor('Component',
|
const ClassDescriptor('Component', 'package:angular2/metadata.dart',
|
||||||
'package:angular2/src/core/annotations_impl/annotations.dart',
|
|
||||||
superClass: 'Directive'),
|
|
||||||
const ClassDescriptor('Component', 'package:angular2/annotations.dart',
|
|
||||||
superClass: 'Directive'),
|
superClass: 'Directive'),
|
||||||
const ClassDescriptor('Component', 'package:angular2/angular2.dart',
|
const ClassDescriptor('Component', 'package:angular2/angular2.dart',
|
||||||
superClass: 'Directive'),
|
superClass: 'Directive'),
|
||||||
const ClassDescriptor('Component', 'package:angular2/bootstrap_static.dart',
|
const ClassDescriptor('Component', 'package:angular2/bootstrap_static.dart',
|
||||||
superClass: 'Directive'),
|
superClass: 'Directive'),
|
||||||
const ClassDescriptor('Component', 'package:angular2/core.dart',
|
const ClassDescriptor('Component', 'package:angular2/core.dart',
|
||||||
superClass: 'Directive'),
|
superClass: '`Directive'),
|
||||||
];
|
];
|
||||||
|
|
||||||
const VIEWS = const [
|
const VIEWS = const [
|
||||||
const ClassDescriptor('View', 'package:angular2/view.dart'),
|
|
||||||
const ClassDescriptor('View', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('View', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor('View', 'package:angular2/bootstrap_static.dart'),
|
const ClassDescriptor('View', 'package:angular2/bootstrap_static.dart'),
|
||||||
const ClassDescriptor('View', 'package:angular2/core.dart'),
|
const ClassDescriptor('View', 'package:angular2/core.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor('View', 'package:angular2/src/core/metadata/view.dart'),
|
||||||
'View', 'package:angular2/src/core/annotations/view.dart'),
|
const ClassDescriptor('View', 'package:angular2/src/core/metadata.dart'),
|
||||||
const ClassDescriptor(
|
|
||||||
'View', 'package:angular2/src/core/annotations_impl/view.dart'),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Checks if a given [Annotation] matches any of the given
|
/// Checks if a given [Annotation] matches any of the given
|
||||||
|
|
|
@ -4,10 +4,10 @@ import 'package:analyzer/analyzer.dart';
|
||||||
import 'package:analyzer/src/generated/element.dart';
|
import 'package:analyzer/src/generated/element.dart';
|
||||||
import 'package:angular2/src/render/api.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
|
/// instance of [Annotation], [NodeList<Annotation>], ListLiteral, or
|
||||||
/// [InstanceCreationExpression].
|
/// [InstanceCreationExpression].
|
||||||
DirectiveMetadata readDirectiveMetadata(dynamic node) {
|
RenderDirectiveMetadata readDirectiveMetadata(dynamic node) {
|
||||||
assert(node is Annotation ||
|
assert(node is Annotation ||
|
||||||
node is NodeList ||
|
node is NodeList ||
|
||||||
node is InstanceCreationExpression ||
|
node is InstanceCreationExpression ||
|
||||||
|
@ -22,10 +22,10 @@ num _getDirectiveType(String annotationName, Element element) {
|
||||||
// TODO(kegluneq): Detect subtypes & implementations of `Directive`s.
|
// TODO(kegluneq): Detect subtypes & implementations of `Directive`s.
|
||||||
switch (annotationName) {
|
switch (annotationName) {
|
||||||
case 'Directive':
|
case 'Directive':
|
||||||
byNameMatch = DirectiveMetadata.DIRECTIVE_TYPE;
|
byNameMatch = RenderDirectiveMetadata.DIRECTIVE_TYPE;
|
||||||
break;
|
break;
|
||||||
case 'Component':
|
case 'Component':
|
||||||
byNameMatch = DirectiveMetadata.COMPONENT_TYPE;
|
byNameMatch = RenderDirectiveMetadata.COMPONENT_TYPE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -34,8 +34,8 @@ num _getDirectiveType(String annotationName, Element element) {
|
||||||
var byResolvedAst = -1;
|
var byResolvedAst = -1;
|
||||||
var libName = element.library.name;
|
var libName = element.library.name;
|
||||||
// If we have resolved, ensure the library is correct.
|
// If we have resolved, ensure the library is correct.
|
||||||
if (libName == 'angular2.src.core.annotations.annotations' ||
|
if (libName == 'angular2.src.core.metadata.directives' ||
|
||||||
libName == 'angular2.src.core.annotations_impl.annotations') {
|
libName == 'angular2.src.core.metadata') {
|
||||||
byResolvedAst = byNameMatch;
|
byResolvedAst = byNameMatch;
|
||||||
}
|
}
|
||||||
// TODO(kegluneq): @keertip, can we expose this as a warning?
|
// 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
|
/// 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
|
class _DirectiveMetadataVisitor extends Object
|
||||||
with RecursiveAstVisitor<Object> {
|
with RecursiveAstVisitor<Object> {
|
||||||
bool get _hasMeta => _type != null;
|
bool get _hasMeta => _type != null;
|
||||||
|
@ -87,7 +87,7 @@ class _DirectiveMetadataVisitor extends Object
|
||||||
_events = [];
|
_events = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectiveMetadata get meta => DirectiveMetadata.create(
|
RenderDirectiveMetadata get meta => RenderDirectiveMetadata.create(
|
||||||
type: _type,
|
type: _type,
|
||||||
selector: _selector,
|
selector: _selector,
|
||||||
compileChildren: _compileChildren,
|
compileChildren: _compileChildren,
|
||||||
|
|
|
@ -11,32 +11,32 @@ export 'class_matcher_base.dart' show ClassDescriptor;
|
||||||
/// covers all libraries which provide them.
|
/// covers all libraries which provide them.
|
||||||
const _ON_CHANGE_INTERFACES = const [
|
const _ON_CHANGE_INTERFACES = const [
|
||||||
const ClassDescriptor('OnChange', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('OnChange', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor('OnChange', 'package:angular2/annotations.dart'),
|
const ClassDescriptor('OnChange', 'package:angular2/metadata.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnChange', 'package:angular2/src/core/compiler/interfaces.dart'),
|
'OnChange', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||||
];
|
];
|
||||||
const _ON_DESTROY_INTERFACES = const [
|
const _ON_DESTROY_INTERFACES = const [
|
||||||
const ClassDescriptor('OnDestroy', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('OnDestroy', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor('OnDestroy', 'package:angular2/annotations.dart'),
|
const ClassDescriptor('OnDestroy', 'package:angular2/metadata.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnDestroy', 'package:angular2/src/core/compiler/interfaces.dart'),
|
'OnDestroy', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||||
];
|
];
|
||||||
const _ON_CHECK_INTERFACES = const [
|
const _ON_CHECK_INTERFACES = const [
|
||||||
const ClassDescriptor('OnCheck', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('OnCheck', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor('OnCheck', 'package:angular2/annotations.dart'),
|
const ClassDescriptor('OnCheck', 'package:angular2/metadata.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnCheck', 'package:angular2/src/core/compiler/interfaces.dart'),
|
'OnCheck', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||||
];
|
];
|
||||||
const _ON_INIT_INTERFACES = const [
|
const _ON_INIT_INTERFACES = const [
|
||||||
const ClassDescriptor('OnInit', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('OnInit', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor('OnInit', 'package:angular2/annotations.dart'),
|
const ClassDescriptor('OnInit', 'package:angular2/metadata.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnInit', 'package:angular2/src/core/compiler/interfaces.dart'),
|
'OnInit', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||||
];
|
];
|
||||||
const _ON_ALL_CHANGES_DONE_INTERFACES = const [
|
const _ON_ALL_CHANGES_DONE_INTERFACES = const [
|
||||||
const ClassDescriptor('OnAllChangesDone', 'package:angular2/angular2.dart'),
|
const ClassDescriptor('OnAllChangesDone', 'package:angular2/angular2.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnAllChangesDone', 'package:angular2/annotations.dart'),
|
'OnAllChangesDone', 'package:angular2/metadata.dart'),
|
||||||
const ClassDescriptor(
|
const ClassDescriptor(
|
||||||
'OnAllChangesDone', 'package:angular2/src/core/compiler/interfaces.dart')
|
'OnAllChangesDone', 'package:angular2/src/core/compiler/interfaces.dart')
|
||||||
];
|
];
|
||||||
|
|
|
@ -20,7 +20,7 @@ import 'logging.dart';
|
||||||
/// easier.
|
/// easier.
|
||||||
class NgMeta {
|
class NgMeta {
|
||||||
/// Directive metadata for each type annotated as a directive.
|
/// 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.
|
/// List of other types and names associated with a given name.
|
||||||
final Map<String, List<String>> aliases;
|
final Map<String, List<String>> aliases;
|
||||||
|
@ -66,7 +66,7 @@ class NgMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the metadata for every type associated with the given [alias].
|
/// Returns the metadata for every type associated with the given [alias].
|
||||||
List<DirectiveMetadata> flatten(String alias) {
|
List<RenderDirectiveMetadata> flatten(String alias) {
|
||||||
var result = [];
|
var result = [];
|
||||||
var seen = new Set();
|
var seen = new Set();
|
||||||
helper(name) {
|
helper(name) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ class RegisteredType {
|
||||||
/// The annotations registered.
|
/// The annotations registered.
|
||||||
final Expression annotations;
|
final Expression annotations;
|
||||||
|
|
||||||
DirectiveMetadata _directiveMetadata = null;
|
RenderDirectiveMetadata _directiveMetadata = null;
|
||||||
|
|
||||||
RegisteredType._(this.typeName, this.registerMethod, this.factoryFn,
|
RegisteredType._(this.typeName, this.registerMethod, this.factoryFn,
|
||||||
this.parameters, this.annotations);
|
this.parameters, this.annotations);
|
||||||
|
@ -37,7 +37,7 @@ class RegisteredType {
|
||||||
visitor.factoryFn, visitor.parameters, visitor.annotations);
|
visitor.factoryFn, visitor.parameters, visitor.annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectiveMetadata get directiveMetadata {
|
RenderDirectiveMetadata get directiveMetadata {
|
||||||
if (_directiveMetadata == null) {
|
if (_directiveMetadata == null) {
|
||||||
try {
|
try {
|
||||||
_directiveMetadata = readDirectiveMetadata(annotations);
|
_directiveMetadata = readDirectiveMetadata(annotations);
|
||||||
|
|
|
@ -3,7 +3,7 @@ library angular2.transform.directive_processor.visitors;
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:analyzer/analyzer.dart';
|
import 'package:analyzer/analyzer.dart';
|
||||||
import 'package:analyzer/src/generated/java_core.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/render/xhr.dart' show XHR;
|
||||||
import 'package:angular2/src/transform/common/annotation_matcher.dart';
|
import 'package:angular2/src/transform/common/annotation_matcher.dart';
|
||||||
import 'package:angular2/src/transform/common/async_string_writer.dart';
|
import 'package:angular2/src/transform/common/async_string_writer.dart';
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ViewDefinitionResults {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewDefinitionEntry {
|
class ViewDefinitionEntry {
|
||||||
final DirectiveMetadata hostMetadata;
|
final RenderDirectiveMetadata hostMetadata;
|
||||||
final ViewDefinition viewDef;
|
final ViewDefinition viewDef;
|
||||||
|
|
||||||
ViewDefinitionEntry._(this.hostMetadata, this.viewDef);
|
ViewDefinitionEntry._(this.hostMetadata, this.viewDef);
|
||||||
|
@ -113,7 +113,7 @@ class _ViewDefinitionCreator {
|
||||||
|
|
||||||
/// Reads the `.ng_meta.json` files associated with all of `entryPoint`'s
|
/// Reads the `.ng_meta.json` files associated with all of `entryPoint`'s
|
||||||
/// imports and creates a map `Type` name, prefixed if appropriate to the
|
/// imports and creates a map `Type` name, prefixed if appropriate to the
|
||||||
/// associated [DirectiveMetadata].
|
/// associated [RenderDirectiveMetadata].
|
||||||
///
|
///
|
||||||
/// For example, if in `entryPoint` we have:
|
/// 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
|
/// 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
|
/// `Directive`s declared in `component.dart`. We use this information to
|
||||||
/// build a map:
|
/// build a map:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// {
|
/// {
|
||||||
/// "prefix.MyComponent": [DirectiveMetadata for MyComponent],
|
/// "prefix.MyComponent": [RenderDirectiveMetadata for MyComponent],
|
||||||
/// ...<any other entries>...
|
/// ...<any other entries>...
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -184,7 +184,7 @@ class _TemplateExtractVisitor extends Object with RecursiveAstVisitor<Object> {
|
||||||
@override
|
@override
|
||||||
Object visitInstanceCreationExpression(InstanceCreationExpression node) {
|
Object visitInstanceCreationExpression(InstanceCreationExpression node) {
|
||||||
if (_isViewAnnotation(node)) {
|
if (_isViewAnnotation(node)) {
|
||||||
viewDef = new ViewDefinition(directives: <DirectiveMetadata>[]);
|
viewDef = new ViewDefinition(directives: <RenderDirectiveMetadata>[]);
|
||||||
node.visitChildren(this);
|
node.visitChildren(this);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
library util_decorators;
|
library angular2.core.util.decorators;
|
||||||
|
|
|
@ -53,7 +53,7 @@ export interface TypeDecorator {
|
||||||
// ParameterDecorator is declared in lib.d.ts as a `declare type`
|
// ParameterDecorator is declared in lib.d.ts as a `declare type`
|
||||||
// so we cannot declare this interface as a subtype.
|
// so we cannot declare this interface as a subtype.
|
||||||
// see https://github.com/angular/angular/issues/3379#issuecomment-126169417
|
// 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.
|
* Storage for the accumulated annotations so far used by the DSL syntax.
|
||||||
|
|
|
@ -16,8 +16,8 @@ import {
|
||||||
} from "angular2/src/facade/collection";
|
} from "angular2/src/facade/collection";
|
||||||
import {
|
import {
|
||||||
ProtoViewDto,
|
ProtoViewDto,
|
||||||
DirectiveMetadata,
|
RenderDirectiveMetadata,
|
||||||
ElementBinder,
|
RenderElementBinder,
|
||||||
DirectiveBinder,
|
DirectiveBinder,
|
||||||
ElementPropertyBinding,
|
ElementPropertyBinding,
|
||||||
EventBinding,
|
EventBinding,
|
||||||
|
@ -85,9 +85,9 @@ export class Serializer {
|
||||||
return this._serializeDirectiveBinder(obj);
|
return this._serializeDirectiveBinder(obj);
|
||||||
} else if (type == ProtoViewDto) {
|
} else if (type == ProtoViewDto) {
|
||||||
return this._serializeProtoViewDto(obj);
|
return this._serializeProtoViewDto(obj);
|
||||||
} else if (type == ElementBinder) {
|
} else if (type == RenderElementBinder) {
|
||||||
return this._serializeElementBinder(obj);
|
return this._serializeElementBinder(obj);
|
||||||
} else if (type == DirectiveMetadata) {
|
} else if (type == RenderDirectiveMetadata) {
|
||||||
return this._serializeDirectiveMetadata(obj);
|
return this._serializeDirectiveMetadata(obj);
|
||||||
} else if (type == ASTWithSource) {
|
} else if (type == ASTWithSource) {
|
||||||
return this._serializeASTWithSource(obj);
|
return this._serializeASTWithSource(obj);
|
||||||
|
@ -129,9 +129,9 @@ export class Serializer {
|
||||||
return this._deserializeDirectiveBinder(map);
|
return this._deserializeDirectiveBinder(map);
|
||||||
} else if (type == ProtoViewDto) {
|
} else if (type == ProtoViewDto) {
|
||||||
return this._deserializeProtoViewDto(map);
|
return this._deserializeProtoViewDto(map);
|
||||||
} else if (type == DirectiveMetadata) {
|
} else if (type == RenderDirectiveMetadata) {
|
||||||
return this._deserializeDirectiveMetadata(map);
|
return this._deserializeDirectiveMetadata(map);
|
||||||
} else if (type == ElementBinder) {
|
} else if (type == RenderElementBinder) {
|
||||||
return this._deserializeElementBinder(map);
|
return this._deserializeElementBinder(map);
|
||||||
} else if (type == ASTWithSource) {
|
} else if (type == ASTWithSource) {
|
||||||
return this._deserializeASTWithSource(map, data);
|
return this._deserializeASTWithSource(map, data);
|
||||||
|
@ -271,7 +271,7 @@ export class Serializer {
|
||||||
'componentId': view.componentId,
|
'componentId': view.componentId,
|
||||||
'templateAbsUrl': view.templateAbsUrl,
|
'templateAbsUrl': view.templateAbsUrl,
|
||||||
'template': view.template,
|
'template': view.template,
|
||||||
'directives': this.serialize(view.directives, DirectiveMetadata),
|
'directives': this.serialize(view.directives, RenderDirectiveMetadata),
|
||||||
'styleAbsUrls': view.styleAbsUrls,
|
'styleAbsUrls': view.styleAbsUrls,
|
||||||
'styles': view.styles,
|
'styles': view.styles,
|
||||||
'encapsulation': serializeEnum(view.encapsulation)
|
'encapsulation': serializeEnum(view.encapsulation)
|
||||||
|
@ -282,7 +282,7 @@ export class Serializer {
|
||||||
return new ViewDefinition({
|
return new ViewDefinition({
|
||||||
componentId: obj['componentId'],
|
componentId: obj['componentId'],
|
||||||
templateAbsUrl: obj['templateAbsUrl'], template: obj['template'],
|
templateAbsUrl: obj['templateAbsUrl'], template: obj['template'],
|
||||||
directives: this.deserialize(obj['directives'], DirectiveMetadata),
|
directives: this.deserialize(obj['directives'], RenderDirectiveMetadata),
|
||||||
styleAbsUrls: obj['styleAbsUrls'],
|
styleAbsUrls: obj['styleAbsUrls'],
|
||||||
styles: obj['styles'],
|
styles: obj['styles'],
|
||||||
encapsulation:
|
encapsulation:
|
||||||
|
@ -308,7 +308,7 @@ export class Serializer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _serializeElementBinder(binder: ElementBinder): Object {
|
private _serializeElementBinder(binder: RenderElementBinder): Object {
|
||||||
return {
|
return {
|
||||||
'index': binder.index,
|
'index': binder.index,
|
||||||
'parentIndex': binder.parentIndex,
|
'parentIndex': binder.parentIndex,
|
||||||
|
@ -322,8 +322,8 @@ export class Serializer {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private _deserializeElementBinder(obj: StringMap<string, any>): ElementBinder {
|
private _deserializeElementBinder(obj: StringMap<string, any>): RenderElementBinder {
|
||||||
return new ElementBinder({
|
return new RenderElementBinder({
|
||||||
index: obj['index'],
|
index: obj['index'],
|
||||||
parentIndex: obj['parentIndex'],
|
parentIndex: obj['parentIndex'],
|
||||||
distanceToParent: obj['distanceToParent'],
|
distanceToParent: obj['distanceToParent'],
|
||||||
|
@ -339,7 +339,7 @@ export class Serializer {
|
||||||
private _serializeProtoViewDto(view: ProtoViewDto): Object {
|
private _serializeProtoViewDto(view: ProtoViewDto): Object {
|
||||||
return {
|
return {
|
||||||
'render': this._protoViewStore.serialize(view.render),
|
'render': this._protoViewStore.serialize(view.render),
|
||||||
'elementBinders': this.serialize(view.elementBinders, ElementBinder),
|
'elementBinders': this.serialize(view.elementBinders, RenderElementBinder),
|
||||||
'variableBindings': this.mapToObject(view.variableBindings),
|
'variableBindings': this.mapToObject(view.variableBindings),
|
||||||
'type': serializeEnum(view.type),
|
'type': serializeEnum(view.type),
|
||||||
'textBindings': this.serialize(view.textBindings, ASTWithSource),
|
'textBindings': this.serialize(view.textBindings, ASTWithSource),
|
||||||
|
@ -350,7 +350,7 @@ export class Serializer {
|
||||||
private _deserializeProtoViewDto(obj: StringMap<string, any>): ProtoViewDto {
|
private _deserializeProtoViewDto(obj: StringMap<string, any>): ProtoViewDto {
|
||||||
return new ProtoViewDto({
|
return new ProtoViewDto({
|
||||||
render: this._protoViewStore.deserialize(obj["render"]),
|
render: this._protoViewStore.deserialize(obj["render"]),
|
||||||
elementBinders: this.deserialize(obj['elementBinders'], ElementBinder),
|
elementBinders: this.deserialize(obj['elementBinders'], RenderElementBinder),
|
||||||
variableBindings: this.objectToMap(obj['variableBindings']),
|
variableBindings: this.objectToMap(obj['variableBindings']),
|
||||||
textBindings: this.deserialize(obj['textBindings'], ASTWithSource, "interpolation"),
|
textBindings: this.deserialize(obj['textBindings'], ASTWithSource, "interpolation"),
|
||||||
type: deserializeEnum(obj['type'], this._enumRegistry.get(ViewType)),
|
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 = {
|
var obj = {
|
||||||
'id': meta.id,
|
'id': meta.id,
|
||||||
'selector': meta.selector,
|
'selector': meta.selector,
|
||||||
|
@ -381,8 +381,8 @@ export class Serializer {
|
||||||
};
|
};
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
private _deserializeDirectiveMetadata(obj: StringMap<string, any>): DirectiveMetadata {
|
private _deserializeDirectiveMetadata(obj: StringMap<string, any>): RenderDirectiveMetadata {
|
||||||
return new DirectiveMetadata({
|
return new RenderDirectiveMetadata({
|
||||||
id: obj['id'],
|
id: obj['id'],
|
||||||
selector: obj['selector'],
|
selector: obj['selector'],
|
||||||
compileChildren: obj['compileChildren'],
|
compileChildren: obj['compileChildren'],
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {createInjector} from "./di_bindings";
|
||||||
import {
|
import {
|
||||||
Renderer,
|
Renderer,
|
||||||
RenderCompiler,
|
RenderCompiler,
|
||||||
DirectiveMetadata,
|
RenderDirectiveMetadata,
|
||||||
ProtoViewDto,
|
ProtoViewDto,
|
||||||
ViewDefinition,
|
ViewDefinition,
|
||||||
RenderProtoViewRef,
|
RenderProtoViewRef,
|
||||||
|
@ -94,7 +94,7 @@ export class WebWorkerMain {
|
||||||
var promise: Promise<any>;
|
var promise: Promise<any>;
|
||||||
switch (data.method) {
|
switch (data.method) {
|
||||||
case "compileHost":
|
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);
|
promise = this._renderCompiler.compileHost(directiveMetadata);
|
||||||
this._wrapWebWorkerPromise(data.id, promise, ProtoViewDto);
|
this._wrapWebWorkerPromise(data.id, promise, ProtoViewDto);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {
|
import {
|
||||||
Renderer,
|
Renderer,
|
||||||
RenderCompiler,
|
RenderCompiler,
|
||||||
DirectiveMetadata,
|
RenderDirectiveMetadata,
|
||||||
ProtoViewDto,
|
ProtoViewDto,
|
||||||
ViewDefinition,
|
ViewDefinition,
|
||||||
RenderProtoViewRef,
|
RenderProtoViewRef,
|
||||||
|
@ -28,8 +28,8 @@ export class WebWorkerCompiler implements RenderCompiler {
|
||||||
/**
|
/**
|
||||||
* Creats a ProtoViewDto that contains a single nested component with the given componentId.
|
* Creats a ProtoViewDto that contains a single nested component with the given componentId.
|
||||||
*/
|
*/
|
||||||
compileHost(directiveMetadata: DirectiveMetadata): Promise<ProtoViewDto> {
|
compileHost(directiveMetadata: RenderDirectiveMetadata): Promise<ProtoViewDto> {
|
||||||
var fnArgs: List<FnArg> = [new FnArg(directiveMetadata, DirectiveMetadata)];
|
var fnArgs: List<FnArg> = [new FnArg(directiveMetadata, RenderDirectiveMetadata)];
|
||||||
var args: UiArguments = new UiArguments("compiler", "compileHost", fnArgs);
|
var args: UiArguments = new UiArguments("compiler", "compileHost", fnArgs);
|
||||||
return this._messageBroker.runOnUiThread(args, ProtoViewDto);
|
return this._messageBroker.runOnUiThread(args, ProtoViewDto);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ const aContents = '''
|
||||||
library bar.ng_deps.dart;
|
library bar.ng_deps.dart;
|
||||||
|
|
||||||
import 'bar.dart';
|
import 'bar.dart';
|
||||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
import 'package:angular2/src/core/metadata.dart';
|
||||||
|
|
||||||
bool _visited = false;
|
bool _visited = false;
|
||||||
void initReflector(reflector) {
|
void initReflector(reflector) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ const bContents = '''
|
||||||
library b.ng_deps.dart;
|
library b.ng_deps.dart;
|
||||||
|
|
||||||
import 'b.dart';
|
import 'b.dart';
|
||||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
import 'package:angular2/src/core/metadata.dart';
|
||||||
|
|
||||||
bool _visited = false;
|
bool _visited = false;
|
||||||
void initReflector(reflector) {
|
void initReflector(reflector) {
|
||||||
|
@ -60,7 +60,7 @@ const cContents = '''
|
||||||
library c.ng_deps.dart;
|
library c.ng_deps.dart;
|
||||||
|
|
||||||
import 'c.dart';
|
import 'c.dart';
|
||||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
import 'package:angular2/src/core/metadata.dart';
|
||||||
import 'b.dart' as dep;
|
import 'b.dart' as dep;
|
||||||
|
|
||||||
bool _visited = false;
|
bool _visited = false;
|
||||||
|
|
|
@ -24,7 +24,7 @@ Future runBenchmark() async {
|
||||||
const aContents = '''
|
const aContents = '''
|
||||||
library dinner.soup;
|
library dinner.soup;
|
||||||
|
|
||||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
import 'package:angular2/src/core/metadata.dart';
|
||||||
|
|
||||||
@Component(selector: '[soup]')
|
@Component(selector: '[soup]')
|
||||||
class SoupComponent {
|
class SoupComponent {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
import {isPresent, stringify} from 'angular2/src/facade/lang';
|
import {isPresent, stringify} from 'angular2/src/facade/lang';
|
||||||
import {bootstrap, ApplicationRef} from 'angular2/src/core/application';
|
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 {DOM} from 'angular2/src/dom/dom_adapter';
|
||||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||||
import {bind, Inject, Injector} from 'angular2/di';
|
import {bind, Inject, Injector} from 'angular2/di';
|
||||||
|
|
|
@ -22,8 +22,7 @@ import {AppProtoView} from 'angular2/src/core/compiler/view';
|
||||||
import {ElementBinder} from 'angular2/src/core/compiler/element_binder';
|
import {ElementBinder} from 'angular2/src/core/compiler/element_binder';
|
||||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||||
import {PipeResolver} from 'angular2/src/core/compiler/pipe_resolver';
|
import {PipeResolver} from 'angular2/src/core/compiler/pipe_resolver';
|
||||||
import {Attribute, View, Component, Directive, Pipe} from 'angular2/annotations';
|
import {Attribute, ViewMetadata, Component, Directive, Pipe} from 'angular2/metadata';
|
||||||
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
|
|
||||||
import {internalProtoView} from 'angular2/src/core/compiler/view_ref';
|
import {internalProtoView} from 'angular2/src/core/compiler/view_ref';
|
||||||
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
||||||
import {ViewResolver} from 'angular2/src/core/compiler/view_resolver';
|
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 {UrlResolver} from 'angular2/src/services/url_resolver';
|
||||||
import {AppRootUrl} from 'angular2/src/services/app_root_url';
|
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...
|
// TODO(tbosch): Spys don't support named modules...
|
||||||
import {RenderCompiler} from 'angular2/src/render/api';
|
import {RenderCompiler} from 'angular2/src/render/api';
|
||||||
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
|
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
|
||||||
|
@ -48,8 +56,7 @@ export function main() {
|
||||||
cmpUrlMapper, rootProtoView;
|
cmpUrlMapper, rootProtoView;
|
||||||
var renderCompileRequests: any[];
|
var renderCompileRequests: any[];
|
||||||
|
|
||||||
function createCompiler(renderCompileResults:
|
function createCompiler(renderCompileResults: List<ProtoViewDto | Promise<ProtoViewDto>>,
|
||||||
List<renderApi.ProtoViewDto | Promise<renderApi.ProtoViewDto>>,
|
|
||||||
protoViewFactoryResults: List<AppProtoView>) {
|
protoViewFactoryResults: List<AppProtoView>) {
|
||||||
var urlResolver = new UrlResolver();
|
var urlResolver = new UrlResolver();
|
||||||
renderCompileRequests = [];
|
renderCompileRequests = [];
|
||||||
|
@ -73,12 +80,12 @@ export function main() {
|
||||||
renderCompiler = new SpyRenderCompiler();
|
renderCompiler = new SpyRenderCompiler();
|
||||||
renderCompiler.spy('compileHost')
|
renderCompiler.spy('compileHost')
|
||||||
.andCallFake((componentId) => {
|
.andCallFake((componentId) => {
|
||||||
return PromiseWrapper.resolve(createRenderProtoView(
|
return PromiseWrapper.resolve(
|
||||||
[createRenderComponentElementBinder(0)], renderApi.ViewType.HOST));
|
createRenderProtoView([createRenderComponentElementBinder(0)], ViewType.HOST));
|
||||||
});
|
});
|
||||||
renderCompiler.spy('mergeProtoViewsRecursively')
|
renderCompiler.spy('mergeProtoViewsRecursively')
|
||||||
.andCallFake((protoViewRefs: List<renderApi.RenderProtoViewRef | List<any>>) => {
|
.andCallFake((protoViewRefs: List<RenderProtoViewRef | List<any>>) => {
|
||||||
return PromiseWrapper.resolve(new renderApi.RenderProtoViewMergeMapping(
|
return PromiseWrapper.resolve(new RenderProtoViewMergeMapping(
|
||||||
new MergedRenderProtoViewRef(protoViewRefs), 1, [], 0, [], [], [null]));
|
new MergedRenderProtoViewRef(protoViewRefs), 1, [], 0, [], [], [null]));
|
||||||
});
|
});
|
||||||
// TODO spy on .compile and return RenderProtoViewRef, same for compileHost
|
// TODO spy on .compile and return RenderProtoViewRef, same for compileHost
|
||||||
|
@ -87,7 +94,7 @@ export function main() {
|
||||||
|
|
||||||
describe('serialize template', () => {
|
describe('serialize template', () => {
|
||||||
|
|
||||||
function captureTemplate(template: viewAnn.View): Promise<renderApi.ViewDefinition> {
|
function captureTemplate(template: ViewMetadata): Promise<ViewDefinition> {
|
||||||
tplResolver.setView(MainComponent, template);
|
tplResolver.setView(MainComponent, template);
|
||||||
var compiler =
|
var compiler =
|
||||||
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
||||||
|
@ -98,8 +105,8 @@ export function main() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function captureDirective(directive): Promise<renderApi.DirectiveMetadata> {
|
function captureDirective(directive): Promise<RenderDirectiveMetadata> {
|
||||||
return captureTemplate(new viewAnn.View({template: '<div></div>', directives: [directive]}))
|
return captureTemplate(new ViewMetadata({template: '<div></div>', directives: [directive]}))
|
||||||
.then((renderTpl) => {
|
.then((renderTpl) => {
|
||||||
expect(renderTpl.directives.length).toBe(1);
|
expect(renderTpl.directives.length).toBe(1);
|
||||||
return renderTpl.directives[0];
|
return renderTpl.directives[0];
|
||||||
|
@ -107,7 +114,7 @@ export function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should fill the componentId', inject([AsyncTestCompleter], (async) => {
|
it('should fill the componentId', inject([AsyncTestCompleter], (async) => {
|
||||||
captureTemplate(new viewAnn.View({template: '<div></div>'}))
|
captureTemplate(new ViewMetadata({template: '<div></div>'}))
|
||||||
.then((renderTpl) => {
|
.then((renderTpl) => {
|
||||||
expect(renderTpl.componentId).toEqual(stringify(MainComponent));
|
expect(renderTpl.componentId).toEqual(stringify(MainComponent));
|
||||||
async.done();
|
async.done();
|
||||||
|
@ -115,7 +122,7 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should fill inline template', inject([AsyncTestCompleter], (async) => {
|
it('should fill inline template', inject([AsyncTestCompleter], (async) => {
|
||||||
captureTemplate(new viewAnn.View({template: '<div></div>'}))
|
captureTemplate(new ViewMetadata({template: '<div></div>'}))
|
||||||
.then((renderTpl) => {
|
.then((renderTpl) => {
|
||||||
expect(renderTpl.template).toEqual('<div></div>');
|
expect(renderTpl.template).toEqual('<div></div>');
|
||||||
async.done();
|
async.done();
|
||||||
|
@ -125,7 +132,7 @@ export function main() {
|
||||||
it('should fill templateAbsUrl given inline templates',
|
it('should fill templateAbsUrl given inline templates',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
|
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
|
||||||
captureTemplate(new viewAnn.View({template: '<div></div>'}))
|
captureTemplate(new ViewMetadata({template: '<div></div>'}))
|
||||||
.then((renderTpl) => {
|
.then((renderTpl) => {
|
||||||
expect(renderTpl.templateAbsUrl).toEqual('http://www.app.com/cmp/main.js');
|
expect(renderTpl.templateAbsUrl).toEqual('http://www.app.com/cmp/main.js');
|
||||||
async.done();
|
async.done();
|
||||||
|
@ -135,7 +142,7 @@ export function main() {
|
||||||
it('should not fill templateAbsUrl given no inline template or template url',
|
it('should not fill templateAbsUrl given no inline template or template url',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
|
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
|
||||||
captureTemplate(new viewAnn.View({template: null, templateUrl: null}))
|
captureTemplate(new ViewMetadata({template: null, templateUrl: null}))
|
||||||
.then((renderTpl) => {
|
.then((renderTpl) => {
|
||||||
expect(renderTpl.templateAbsUrl).toBe(null);
|
expect(renderTpl.templateAbsUrl).toBe(null);
|
||||||
async.done();
|
async.done();
|
||||||
|
@ -144,7 +151,7 @@ export function main() {
|
||||||
|
|
||||||
it('should fill templateAbsUrl given url template', inject([AsyncTestCompleter], (async) => {
|
it('should fill templateAbsUrl given url template', inject([AsyncTestCompleter], (async) => {
|
||||||
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
|
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
|
||||||
captureTemplate(new viewAnn.View({templateUrl: 'tpl/main.html'}))
|
captureTemplate(new ViewMetadata({templateUrl: 'tpl/main.html'}))
|
||||||
.then((renderTpl) => {
|
.then((renderTpl) => {
|
||||||
expect(renderTpl.templateAbsUrl).toEqual('http://www.app.com/cmp/tpl/main.html');
|
expect(renderTpl.templateAbsUrl).toEqual('http://www.app.com/cmp/tpl/main.html');
|
||||||
async.done();
|
async.done();
|
||||||
|
@ -153,7 +160,7 @@ export function main() {
|
||||||
|
|
||||||
it('should fill styleAbsUrls given styleUrls', inject([AsyncTestCompleter], (async) => {
|
it('should fill styleAbsUrls given styleUrls', inject([AsyncTestCompleter], (async) => {
|
||||||
cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js');
|
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) => {
|
.then((renderTpl) => {
|
||||||
expect(renderTpl.styleAbsUrls)
|
expect(renderTpl.styleAbsUrls)
|
||||||
.toEqual(
|
.toEqual(
|
||||||
|
@ -181,7 +188,7 @@ export function main() {
|
||||||
it('should fill directive.type for components', inject([AsyncTestCompleter], (async) => {
|
it('should fill directive.type for components', inject([AsyncTestCompleter], (async) => {
|
||||||
captureDirective(MainComponent)
|
captureDirective(MainComponent)
|
||||||
.then((renderDir) => {
|
.then((renderDir) => {
|
||||||
expect(renderDir.type).toEqual(renderApi.DirectiveMetadata.COMPONENT_TYPE);
|
expect(renderDir.type).toEqual(RenderDirectiveMetadata.COMPONENT_TYPE);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
@ -190,7 +197,7 @@ export function main() {
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
captureDirective(SomeDynamicComponentDirective)
|
captureDirective(SomeDynamicComponentDirective)
|
||||||
.then((renderDir) => {
|
.then((renderDir) => {
|
||||||
expect(renderDir.type).toEqual(renderApi.DirectiveMetadata.COMPONENT_TYPE);
|
expect(renderDir.type).toEqual(RenderDirectiveMetadata.COMPONENT_TYPE);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
@ -199,7 +206,7 @@ export function main() {
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
captureDirective(SomeDirective)
|
captureDirective(SomeDirective)
|
||||||
.then((renderDir) => {
|
.then((renderDir) => {
|
||||||
expect(renderDir.type).toEqual(renderApi.DirectiveMetadata.DIRECTIVE_TYPE);
|
expect(renderDir.type).toEqual(RenderDirectiveMetadata.DIRECTIVE_TYPE);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
@ -269,7 +276,7 @@ export function main() {
|
||||||
describe('call ProtoViewFactory', () => {
|
describe('call ProtoViewFactory', () => {
|
||||||
|
|
||||||
it('should pass the ProtoViewDto', inject([AsyncTestCompleter], (async) => {
|
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 renderProtoView = createRenderProtoView();
|
||||||
var expectedProtoView = createProtoView();
|
var expectedProtoView = createProtoView();
|
||||||
var compiler = createCompiler([renderProtoView], [rootProtoView, expectedProtoView]);
|
var compiler = createCompiler([renderProtoView], [rootProtoView, expectedProtoView]);
|
||||||
|
@ -282,7 +289,7 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should pass the component binding', inject([AsyncTestCompleter], (async) => {
|
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 =
|
var compiler =
|
||||||
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
||||||
compiler.compileInHost(MainComponent)
|
compiler.compileInHost(MainComponent)
|
||||||
|
@ -296,7 +303,7 @@ export function main() {
|
||||||
it('should pass the directive bindings', inject([AsyncTestCompleter], (async) => {
|
it('should pass the directive bindings', inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(
|
tplResolver.setView(
|
||||||
MainComponent,
|
MainComponent,
|
||||||
new viewAnn.View({template: '<div></div>', directives: [SomeDirective]}));
|
new ViewMetadata({template: '<div></div>', directives: [SomeDirective]}));
|
||||||
var compiler =
|
var compiler =
|
||||||
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
||||||
compiler.compileInHost(MainComponent)
|
compiler.compileInHost(MainComponent)
|
||||||
|
@ -310,7 +317,7 @@ export function main() {
|
||||||
|
|
||||||
it('should pass the pipe bindings', inject([AsyncTestCompleter], (async) => {
|
it('should pass the pipe bindings', inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent,
|
tplResolver.setView(MainComponent,
|
||||||
new viewAnn.View({template: '<div></div>', pipes: [SomePipe]}));
|
new ViewMetadata({template: '<div></div>', pipes: [SomePipe]}));
|
||||||
var compiler =
|
var compiler =
|
||||||
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
||||||
compiler.compileInHost(MainComponent)
|
compiler.compileInHost(MainComponent)
|
||||||
|
@ -324,7 +331,7 @@ export function main() {
|
||||||
|
|
||||||
it('should use the protoView of the ProtoViewFactory',
|
it('should use the protoView of the ProtoViewFactory',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var compiler =
|
var compiler =
|
||||||
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
createCompiler([createRenderProtoView()], [rootProtoView, createProtoView()]);
|
||||||
compiler.compileInHost(MainComponent)
|
compiler.compileInHost(MainComponent)
|
||||||
|
@ -337,8 +344,8 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load nested components', inject([AsyncTestCompleter], (async) => {
|
it('should load nested components', inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
tplResolver.setView(NestedComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(NestedComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var mainProtoView =
|
var mainProtoView =
|
||||||
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]);
|
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]);
|
||||||
var nestedProtoView = createProtoView();
|
var nestedProtoView = createProtoView();
|
||||||
|
@ -361,17 +368,16 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should load nested components in viewcontainers', inject([AsyncTestCompleter], (async) => {
|
it('should load nested components in viewcontainers', inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
tplResolver.setView(NestedComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(NestedComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var viewportProtoView =
|
var viewportProtoView = createProtoView(
|
||||||
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)],
|
[createComponentElementBinder(directiveResolver, NestedComponent)], ViewType.EMBEDDED);
|
||||||
renderApi.ViewType.EMBEDDED);
|
|
||||||
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
|
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
|
||||||
var nestedProtoView = createProtoView();
|
var nestedProtoView = createProtoView();
|
||||||
var renderPvDtos = [
|
var renderPvDtos = [
|
||||||
createRenderProtoView([
|
createRenderProtoView([
|
||||||
createRenderViewportElementBinder(createRenderProtoView(
|
createRenderViewportElementBinder(
|
||||||
[createRenderComponentElementBinder(0)], renderApi.ViewType.EMBEDDED))
|
createRenderProtoView([createRenderComponentElementBinder(0)], ViewType.EMBEDDED))
|
||||||
]),
|
]),
|
||||||
createRenderProtoView()
|
createRenderProtoView()
|
||||||
];
|
];
|
||||||
|
@ -391,7 +397,7 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should cache compiled host components', inject([AsyncTestCompleter], (async) => {
|
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 mainPv = createProtoView();
|
||||||
var compiler = createCompiler([createRenderProtoView([])], [rootProtoView, mainPv]);
|
var compiler = createCompiler([createRenderProtoView([])], [rootProtoView, mainPv]);
|
||||||
compiler.compileInHost(MainComponent)
|
compiler.compileInHost(MainComponent)
|
||||||
|
@ -429,9 +435,9 @@ export function main() {
|
||||||
|
|
||||||
|
|
||||||
it('should cache compiled nested components', inject([AsyncTestCompleter], (async) => {
|
it('should cache compiled nested components', inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
tplResolver.setView(MainComponent2, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent2, new ViewMetadata({template: '<div></div>'}));
|
||||||
tplResolver.setView(NestedComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(NestedComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var rootProtoView2 = createRootProtoView(directiveResolver, MainComponent2);
|
var rootProtoView2 = createRootProtoView(directiveResolver, MainComponent2);
|
||||||
var mainPv =
|
var mainPv =
|
||||||
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]);
|
createProtoView([createComponentElementBinder(directiveResolver, NestedComponent)]);
|
||||||
|
@ -459,9 +465,8 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should re-use components being compiled', inject([AsyncTestCompleter], (async) => {
|
it('should re-use components being compiled', inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var renderProtoViewCompleter: PromiseCompleter<renderApi.ProtoViewDto> =
|
var renderProtoViewCompleter: PromiseCompleter<ProtoViewDto> = PromiseWrapper.completer();
|
||||||
PromiseWrapper.completer();
|
|
||||||
var expectedProtoView = createProtoView();
|
var expectedProtoView = createProtoView();
|
||||||
var compiler = createCompiler([renderProtoViewCompleter.promise],
|
var compiler = createCompiler([renderProtoViewCompleter.promise],
|
||||||
[rootProtoView, rootProtoView, expectedProtoView]);
|
[rootProtoView, rootProtoView, expectedProtoView]);
|
||||||
|
@ -482,7 +487,7 @@ export function main() {
|
||||||
|
|
||||||
it('should throw on unconditional recursive components',
|
it('should throw on unconditional recursive components',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var mainProtoView =
|
var mainProtoView =
|
||||||
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)]);
|
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)]);
|
||||||
var compiler =
|
var compiler =
|
||||||
|
@ -498,15 +503,14 @@ export function main() {
|
||||||
|
|
||||||
it('should allow recursive components that are connected via an embedded ProtoView',
|
it('should allow recursive components that are connected via an embedded ProtoView',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var viewportProtoView =
|
var viewportProtoView = createProtoView(
|
||||||
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)],
|
[createComponentElementBinder(directiveResolver, MainComponent)], ViewType.EMBEDDED);
|
||||||
renderApi.ViewType.EMBEDDED);
|
|
||||||
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
|
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
|
||||||
var renderPvDtos = [
|
var renderPvDtos = [
|
||||||
createRenderProtoView([
|
createRenderProtoView([
|
||||||
createRenderViewportElementBinder(createRenderProtoView(
|
createRenderViewportElementBinder(
|
||||||
[createRenderComponentElementBinder(0)], renderApi.ViewType.EMBEDDED))
|
createRenderProtoView([createRenderComponentElementBinder(0)], ViewType.EMBEDDED))
|
||||||
]),
|
]),
|
||||||
createRenderProtoView()
|
createRenderProtoView()
|
||||||
];
|
];
|
||||||
|
@ -530,15 +534,15 @@ export function main() {
|
||||||
|
|
||||||
it('should throw on recursive components that are connected via an embedded ProtoView with <ng-content>',
|
it('should throw on recursive components that are connected via an embedded ProtoView with <ng-content>',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var viewportProtoView =
|
var viewportProtoView =
|
||||||
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)],
|
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)],
|
||||||
renderApi.ViewType.EMBEDDED, true);
|
ViewType.EMBEDDED, true);
|
||||||
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
|
var mainProtoView = createProtoView([createViewportElementBinder(viewportProtoView)]);
|
||||||
var renderPvDtos = [
|
var renderPvDtos = [
|
||||||
createRenderProtoView([
|
createRenderProtoView([
|
||||||
createRenderViewportElementBinder(createRenderProtoView(
|
createRenderViewportElementBinder(
|
||||||
[createRenderComponentElementBinder(0)], renderApi.ViewType.EMBEDDED))
|
createRenderProtoView([createRenderComponentElementBinder(0)], ViewType.EMBEDDED))
|
||||||
]),
|
]),
|
||||||
createRenderProtoView()
|
createRenderProtoView()
|
||||||
];
|
];
|
||||||
|
@ -554,10 +558,9 @@ export function main() {
|
||||||
|
|
||||||
|
|
||||||
it('should create host proto views', inject([AsyncTestCompleter], (async) => {
|
it('should create host proto views', inject([AsyncTestCompleter], (async) => {
|
||||||
tplResolver.setView(MainComponent, new viewAnn.View({template: '<div></div>'}));
|
tplResolver.setView(MainComponent, new ViewMetadata({template: '<div></div>'}));
|
||||||
var rootProtoView =
|
var rootProtoView = createProtoView(
|
||||||
createProtoView([createComponentElementBinder(directiveResolver, MainComponent)],
|
[createComponentElementBinder(directiveResolver, MainComponent)], ViewType.HOST);
|
||||||
renderApi.ViewType.HOST);
|
|
||||||
var mainProtoView = createProtoView();
|
var mainProtoView = createProtoView();
|
||||||
var compiler = createCompiler([createRenderProtoView()], [rootProtoView, mainProtoView]);
|
var compiler = createCompiler([createRenderProtoView()], [rootProtoView, mainProtoView]);
|
||||||
compiler.compileInHost(MainComponent)
|
compiler.compileInHost(MainComponent)
|
||||||
|
@ -582,13 +585,13 @@ function createDirectiveBinding(directiveResolver, type): DirectiveBinding {
|
||||||
return DirectiveBinding.createFromType(type, annotation);
|
return DirectiveBinding.createFromType(type, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createProtoView(elementBinders = null, type: renderApi.ViewType = null,
|
function createProtoView(elementBinders = null, type: ViewType = null,
|
||||||
isEmbeddedFragment: boolean = false): AppProtoView {
|
isEmbeddedFragment: boolean = false): AppProtoView {
|
||||||
if (isBlank(type)) {
|
if (isBlank(type)) {
|
||||||
type = renderApi.ViewType.COMPONENT;
|
type = ViewType.COMPONENT;
|
||||||
}
|
}
|
||||||
var pv = new AppProtoView(type, isEmbeddedFragment, new renderApi.RenderProtoViewRef(), null,
|
var pv = new AppProtoView(type, isEmbeddedFragment, new RenderProtoViewRef(), null, null,
|
||||||
null, new Map(), null, null);
|
new Map(), null, null);
|
||||||
if (isBlank(elementBinders)) {
|
if (isBlank(elementBinders)) {
|
||||||
elementBinders = [];
|
elementBinders = [];
|
||||||
}
|
}
|
||||||
|
@ -607,30 +610,28 @@ function createViewportElementBinder(nestedProtoView): ElementBinder {
|
||||||
return elBinder;
|
return elBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRenderProtoView(elementBinders = null, type: renderApi.ViewType = null):
|
function createRenderProtoView(elementBinders = null, type: ViewType = null): ProtoViewDto {
|
||||||
renderApi.ProtoViewDto {
|
|
||||||
if (isBlank(type)) {
|
if (isBlank(type)) {
|
||||||
type = renderApi.ViewType.COMPONENT;
|
type = ViewType.COMPONENT;
|
||||||
}
|
}
|
||||||
if (isBlank(elementBinders)) {
|
if (isBlank(elementBinders)) {
|
||||||
elementBinders = [];
|
elementBinders = [];
|
||||||
}
|
}
|
||||||
return new renderApi.ProtoViewDto(
|
return new ProtoViewDto(
|
||||||
{elementBinders: elementBinders, type: type, render: new renderApi.RenderProtoViewRef()});
|
{elementBinders: elementBinders, type: type, render: new RenderProtoViewRef()});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRenderComponentElementBinder(directiveIndex): renderApi.ElementBinder {
|
function createRenderComponentElementBinder(directiveIndex): RenderElementBinder {
|
||||||
return new renderApi.ElementBinder(
|
return new RenderElementBinder(
|
||||||
{directives: [new renderApi.DirectiveBinder({directiveIndex: directiveIndex})]});
|
{directives: [new DirectiveBinder({directiveIndex: directiveIndex})]});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRenderViewportElementBinder(nestedProtoView): renderApi.ElementBinder {
|
function createRenderViewportElementBinder(nestedProtoView): RenderElementBinder {
|
||||||
return new renderApi.ElementBinder({nestedProtoView: nestedProtoView});
|
return new RenderElementBinder({nestedProtoView: nestedProtoView});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRootProtoView(directiveResolver, type): AppProtoView {
|
function createRootProtoView(directiveResolver, type): AppProtoView {
|
||||||
return createProtoView([createComponentElementBinder(directiveResolver, type)],
|
return createProtoView([createComponentElementBinder(directiveResolver, type)], ViewType.HOST);
|
||||||
renderApi.ViewType.HOST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'main-comp'})
|
@Component({selector: 'main-comp'})
|
||||||
|
@ -699,16 +700,16 @@ class SpyDirectiveResolver extends SpyObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeViewResolver extends ViewResolver {
|
class FakeViewResolver extends ViewResolver {
|
||||||
_cmpViews: Map<Type, viewAnn.View> = new Map();
|
_cmpViews: Map<Type, ViewMetadata> = new Map();
|
||||||
|
|
||||||
constructor() { super(); }
|
constructor() { super(); }
|
||||||
|
|
||||||
resolve(component: Type): viewAnn.View {
|
resolve(component: Type): ViewMetadata {
|
||||||
// returns null for dynamic components
|
// returns null for dynamic components
|
||||||
return this._cmpViews.has(component) ? this._cmpViews.get(component) : null;
|
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 {
|
class FakeProtoViewFactory extends ProtoViewFactory {
|
||||||
|
@ -719,15 +720,15 @@ class FakeProtoViewFactory extends ProtoViewFactory {
|
||||||
this.requests = [];
|
this.requests = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
createAppProtoViews(componentBinding: DirectiveBinding, renderProtoView: renderApi.ProtoViewDto,
|
createAppProtoViews(componentBinding: DirectiveBinding, renderProtoView: ProtoViewDto,
|
||||||
directives: List<DirectiveBinding>, pipes: PipeBinding[]): AppProtoView[] {
|
directives: List<DirectiveBinding>, pipes: PipeBinding[]): AppProtoView[] {
|
||||||
this.requests.push([componentBinding, renderProtoView, directives, pipes]);
|
this.requests.push([componentBinding, renderProtoView, directives, pipes]);
|
||||||
return collectEmbeddedPvs(ListWrapper.removeAt(this.results, 0));
|
return collectEmbeddedPvs(ListWrapper.removeAt(this.results, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MergedRenderProtoViewRef extends renderApi.RenderProtoViewRef {
|
class MergedRenderProtoViewRef extends RenderProtoViewRef {
|
||||||
constructor(public originals: renderApi.RenderProtoViewRef[]) { super(); }
|
constructor(public originals: RenderProtoViewRef[]) { super(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function originalRenderProtoViewRefs(appProtoView: AppProtoView) {
|
function originalRenderProtoViewRefs(appProtoView: AppProtoView) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
proxy
|
proxy
|
||||||
} from 'angular2/test_lib';
|
} 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';
|
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
|
@ -25,87 +25,99 @@ export function main() {
|
||||||
|
|
||||||
describe("onChange", () => {
|
describe("onChange", () => {
|
||||||
it("should be true when the directive has the onChange method", () => {
|
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", () => {
|
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)
|
.callOnChange)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise",
|
it("should be false otherwise", () => {
|
||||||
() => { expect(metadata(DirectiveNoHooks, new Directive()).callOnChange).toBe(false); });
|
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnChange).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it("should be false when empty lifecycle", () => {
|
it("should be false when empty lifecycle", () => {
|
||||||
expect(metadata(DirectiveWithOnChangeMethod, new Directive({lifecycle: []})).callOnChange)
|
expect(metadata(DirectiveWithOnChangeMethod, new DirectiveMetadata({lifecycle: []}))
|
||||||
|
.callOnChange)
|
||||||
.toBe(false);
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onDestroy", () => {
|
describe("onDestroy", () => {
|
||||||
it("should be true when the directive has the onDestroy method", () => {
|
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);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onDestroy", () => {
|
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)
|
.callOnDestroy)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () => {
|
it("should be false otherwise", () => {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnDestroy).toBe(false);
|
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnDestroy).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onInit", () => {
|
describe("onInit", () => {
|
||||||
it("should be true when the directive has the onInit method", () => {
|
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", () => {
|
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)
|
.callOnInit)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise",
|
it("should be false otherwise", () => {
|
||||||
() => { expect(metadata(DirectiveNoHooks, new Directive()).callOnInit).toBe(false); });
|
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnInit).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onCheck", () => {
|
describe("onCheck", () => {
|
||||||
it("should be true when the directive has the onCheck method", () => {
|
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", () => {
|
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)
|
.callOnCheck)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise",
|
it("should be false otherwise", () => {
|
||||||
() => { expect(metadata(DirectiveNoHooks, new Directive()).callOnCheck).toBe(false); });
|
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnCheck).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("onAllChangesDone", () => {
|
describe("onAllChangesDone", () => {
|
||||||
it("should be true when the directive has the onAllChangesDone method", () => {
|
it("should be true when the directive has the onAllChangesDone method", () => {
|
||||||
expect(
|
expect(metadata(DirectiveWithOnAllChangesDoneMethod, new DirectiveMetadata({}))
|
||||||
metadata(DirectiveWithOnAllChangesDoneMethod, new Directive({})).callOnAllChangesDone)
|
.callOnAllChangesDone)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be true when the lifecycle includes onAllChangesDone", () => {
|
it("should be true when the lifecycle includes onAllChangesDone", () => {
|
||||||
expect(metadata(DirectiveNoHooks,
|
expect(metadata(DirectiveNoHooks,
|
||||||
new Directive({lifecycle: [LifecycleEvent.onAllChangesDone]}))
|
new DirectiveMetadata({lifecycle: [LifecycleEvent.onAllChangesDone]}))
|
||||||
.callOnAllChangesDone)
|
.callOnAllChangesDone)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be false otherwise", () => {
|
it("should be false otherwise", () => {
|
||||||
expect(metadata(DirectiveNoHooks, new Directive()).callOnAllChangesDone).toBe(false);
|
expect(metadata(DirectiveNoHooks, new DirectiveMetadata()).callOnAllChangesDone)
|
||||||
|
.toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import {ddescribe, describe, it, iit, expect, beforeEach} from 'angular2/test_lib';
|
import {ddescribe, describe, it, iit, expect, beforeEach} from 'angular2/test_lib';
|
||||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||||
import {Directive} from 'angular2/annotations';
|
import {DirectiveMetadata, Directive} from 'angular2/metadata';
|
||||||
import * as dirAnn from 'angular2/src/core/annotations_impl/annotations';
|
|
||||||
|
|
||||||
@Directive({selector: 'someDirective'})
|
@Directive({selector: 'someDirective'})
|
||||||
class SomeDirective {
|
class SomeDirective {
|
||||||
|
@ -21,7 +20,7 @@ export function main() {
|
||||||
|
|
||||||
it('should read out the Directive annotation', () => {
|
it('should read out the Directive annotation', () => {
|
||||||
var directiveMetadata = reader.resolve(SomeDirective);
|
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', () => {
|
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() {
|
it('should not read parent class Directive annotations', function() {
|
||||||
var directiveMetadata = reader.resolve(SomeChildDirective);
|
var directiveMetadata = reader.resolve(SomeChildDirective);
|
||||||
expect(directiveMetadata).toEqual(new dirAnn.Directive({selector: 'someChildDirective'}));
|
expect(directiveMetadata).toEqual(new Directive({selector: 'someChildDirective'}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,7 @@ import {
|
||||||
|
|
||||||
import {Injector} from 'angular2/di';
|
import {Injector} from 'angular2/di';
|
||||||
import {NgIf} from 'angular2/directives';
|
import {NgIf} from 'angular2/directives';
|
||||||
import {Component, View, LifecycleEvent} from 'angular2/annotations';
|
import {Component, View, ViewMetadata, LifecycleEvent} from 'angular2/metadata';
|
||||||
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
|
|
||||||
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
|
import {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
|
||||||
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
|
||||||
import {DOCUMENT} from 'angular2/src/render/render';
|
import {DOCUMENT} from 'angular2/src/render/render';
|
||||||
|
@ -35,7 +34,7 @@ export function main() {
|
||||||
(loader, tcb: TestComponentBuilder, async) => {
|
(loader, tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<location #loc></location>', directives: [Location]}))
|
{template: '<location #loc></location>', directives: [Location]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((tc) => {
|
.then((tc) => {
|
||||||
|
@ -53,7 +52,7 @@ export function main() {
|
||||||
(loader, tcb: TestComponentBuilder, async) => {
|
(loader, tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<location #loc></location>', directives: [Location]}))
|
{template: '<location #loc></location>', directives: [Location]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((tc) => {
|
.then((tc) => {
|
||||||
|
@ -70,13 +69,13 @@ export function main() {
|
||||||
it('should allow to dispose even if the location has been removed',
|
it('should allow to dispose even if the location has been removed',
|
||||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||||
(loader, tcb: TestComponentBuilder, async) => {
|
(loader, tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<child-cmp *ng-if="ctxBoolProp"></child-cmp>',
|
template: '<child-cmp *ng-if="ctxBoolProp"></child-cmp>',
|
||||||
directives: [NgIf, ChildComp]
|
directives: [NgIf, ChildComp]
|
||||||
}))
|
}))
|
||||||
.overrideView(
|
.overrideView(
|
||||||
ChildComp,
|
ChildComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<location #loc></location>', directives: [Location]}))
|
{template: '<location #loc></location>', directives: [Location]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((tc) => {
|
.then((tc) => {
|
||||||
|
@ -103,7 +102,7 @@ export function main() {
|
||||||
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
[DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||||
(loader, tcb: TestComponentBuilder, async) => {
|
(loader, tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp, new viewAnn.View(
|
MyComp, new ViewMetadata(
|
||||||
{template: '<location #loc></location>', directives: [Location]}))
|
{template: '<location #loc></location>', directives: [Location]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((tc) => {
|
.then((tc) => {
|
||||||
|
@ -125,7 +124,7 @@ export function main() {
|
||||||
(loader, tcb: TestComponentBuilder, async) => {
|
(loader, tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<location #loc></location>', directives: [Location]}))
|
{template: '<location #loc></location>', directives: [Location]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((tc) => {
|
.then((tc) => {
|
||||||
|
@ -140,7 +139,8 @@ export function main() {
|
||||||
describe("loading next to a location", () => {
|
describe("loading next to a location", () => {
|
||||||
it('should work', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
it('should work', inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||||
(loader, tcb: TestComponentBuilder, async) => {
|
(loader, tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template: '<div><location #loc></location></div>',
|
template: '<div><location #loc></location></div>',
|
||||||
directives: [Location]
|
directives: [Location]
|
||||||
}))
|
}))
|
||||||
|
@ -160,7 +160,7 @@ export function main() {
|
||||||
it('should return a disposable component ref',
|
it('should return a disposable component ref',
|
||||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||||
(loader, tcb: TestComponentBuilder, async) => {
|
(loader, tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div><location #loc></location></div>',
|
template: '<div><location #loc></location></div>',
|
||||||
directives: [Location]
|
directives: [Location]
|
||||||
}))
|
}))
|
||||||
|
@ -193,7 +193,7 @@ export function main() {
|
||||||
it('should update host properties',
|
it('should update host properties',
|
||||||
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
|
||||||
(loader, tcb: TestComponentBuilder, async) => {
|
(loader, tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div><location #loc></location></div>',
|
template: '<div><location #loc></location></div>',
|
||||||
directives: [Location]
|
directives: [Location]
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -32,14 +32,13 @@ import {
|
||||||
DirectiveBinding,
|
DirectiveBinding,
|
||||||
TreeNode
|
TreeNode
|
||||||
} from 'angular2/src/core/compiler/element_injector';
|
} from 'angular2/src/core/compiler/element_injector';
|
||||||
import * as dirAnn from 'angular2/src/core/annotations_impl/annotations';
|
|
||||||
import {
|
import {
|
||||||
Attribute,
|
Attribute,
|
||||||
Query,
|
Query,
|
||||||
Component,
|
ComponentMetadata,
|
||||||
Directive,
|
DirectiveMetadata,
|
||||||
LifecycleEvent
|
LifecycleEvent
|
||||||
} from 'angular2/annotations';
|
} from 'angular2/metadata';
|
||||||
import {bind, Injector, Binding, Optional, Inject, Injectable, Self, SkipSelf, InjectMetadata, Host, HostMetadata, SkipSelfMetadata} from 'angular2/di';
|
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 {AppProtoView, AppView} from 'angular2/src/core/compiler/view';
|
||||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||||
|
@ -420,7 +419,7 @@ export function main() {
|
||||||
describe('event emitters', () => {
|
describe('event emitters', () => {
|
||||||
it('should return a list of event accessors', () => {
|
it('should return a list of event accessors', () => {
|
||||||
var binding = DirectiveBinding.createFromType(HasEventEmitter,
|
var binding = DirectiveBinding.createFromType(HasEventEmitter,
|
||||||
new dirAnn.Directive({events: ['emitter']}));
|
new DirectiveMetadata({events: ['emitter']}));
|
||||||
|
|
||||||
var inj = createPei(null, 0, [binding]);
|
var inj = createPei(null, 0, [binding]);
|
||||||
expect(inj.eventEmitterAccessors.length).toEqual(1);
|
expect(inj.eventEmitterAccessors.length).toEqual(1);
|
||||||
|
@ -432,7 +431,7 @@ export function main() {
|
||||||
|
|
||||||
it('should allow a different event vs field name', () => {
|
it('should allow a different event vs field name', () => {
|
||||||
var binding = DirectiveBinding.createFromType(HasEventEmitter,
|
var binding = DirectiveBinding.createFromType(HasEventEmitter,
|
||||||
new dirAnn.Directive({events: ['emitter: publicEmitter']}));
|
new DirectiveMetadata({events: ['emitter: publicEmitter']}));
|
||||||
|
|
||||||
var inj = createPei(null, 0, [binding]);
|
var inj = createPei(null, 0, [binding]);
|
||||||
expect(inj.eventEmitterAccessors.length).toEqual(1);
|
expect(inj.eventEmitterAccessors.length).toEqual(1);
|
||||||
|
@ -444,7 +443,7 @@ export function main() {
|
||||||
|
|
||||||
it('should return a list of hostAction accessors', () => {
|
it('should return a list of hostAction accessors', () => {
|
||||||
var binding = DirectiveBinding.createFromType(
|
var binding = DirectiveBinding.createFromType(
|
||||||
HasEventEmitter, new dirAnn.Directive({host: {'@hostActionName': 'onAction'}}));
|
HasEventEmitter, new DirectiveMetadata({host: {'@hostActionName': 'onAction'}}));
|
||||||
|
|
||||||
var inj = createPei(null, 0, [binding]);
|
var inj = createPei(null, 0, [binding]);
|
||||||
expect(inj.hostActionAccessors.length).toEqual(1);
|
expect(inj.hostActionAccessors.length).toEqual(1);
|
||||||
|
@ -460,8 +459,8 @@ export function main() {
|
||||||
var pei = createPei(null, 0, [
|
var pei = createPei(null, 0, [
|
||||||
DirectiveBinding.createFromType(
|
DirectiveBinding.createFromType(
|
||||||
SimpleDirective,
|
SimpleDirective,
|
||||||
new dirAnn.Component({bindings: [bind('injectable1').toValue('injectable1')]})),
|
new ComponentMetadata({bindings: [bind('injectable1').toValue('injectable1')]})),
|
||||||
DirectiveBinding.createFromType(SomeOtherDirective, new dirAnn.Component({
|
DirectiveBinding.createFromType(SomeOtherDirective, new ComponentMetadata({
|
||||||
bindings: [bind('injectable2').toValue('injectable2')]
|
bindings: [bind('injectable2').toValue('injectable2')]
|
||||||
}))
|
}))
|
||||||
]);
|
]);
|
||||||
|
@ -474,7 +473,7 @@ export function main() {
|
||||||
|
|
||||||
it("should collect view bindings from the component", () => {
|
it("should collect view bindings from the component", () => {
|
||||||
var pei = createPei(null, 0,
|
var pei = createPei(null, 0,
|
||||||
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
|
[DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
|
||||||
viewBindings: [bind('injectable1').toValue('injectable1')]
|
viewBindings: [bind('injectable1').toValue('injectable1')]
|
||||||
}))],
|
}))],
|
||||||
0, true);
|
0, true);
|
||||||
|
@ -487,7 +486,7 @@ export function main() {
|
||||||
var pei = createPei(null, 0, [
|
var pei = createPei(null, 0, [
|
||||||
DirectiveBinding.createFromType(
|
DirectiveBinding.createFromType(
|
||||||
SimpleDirective,
|
SimpleDirective,
|
||||||
new dirAnn.Component({
|
new ComponentMetadata({
|
||||||
viewBindings: [[[bind('view').toValue('view')]]],
|
viewBindings: [[[bind('view').toValue('view')]]],
|
||||||
bindings: [[[bind('host').toValue('host')]]]
|
bindings: [[[bind('host').toValue('host')]]]
|
||||||
}))
|
}))
|
||||||
|
@ -595,11 +594,11 @@ export function main() {
|
||||||
function() {
|
function() {
|
||||||
var childInj = parentChildInjectors(
|
var childInj = parentChildInjectors(
|
||||||
ListWrapper.concat(
|
ListWrapper.concat(
|
||||||
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
|
[DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
|
||||||
bindings: [bind('injectable1').toValue('injectable1')]
|
bindings: [bind('injectable1').toValue('injectable1')]
|
||||||
}))],
|
}))],
|
||||||
extraBindings),
|
extraBindings),
|
||||||
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
|
[DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
|
||||||
bindings: [
|
bindings: [
|
||||||
bind('injectable1')
|
bind('injectable1')
|
||||||
.toValue('new-injectable1'),
|
.toValue('new-injectable1'),
|
||||||
|
@ -624,7 +623,7 @@ export function main() {
|
||||||
|
|
||||||
var inj = injector(ListWrapper.concat(
|
var inj = injector(ListWrapper.concat(
|
||||||
[DirectiveBinding.createFromType(SimpleDirective,
|
[DirectiveBinding.createFromType(SimpleDirective,
|
||||||
new dirAnn.Directive({bindings: bindings}))],
|
new DirectiveMetadata({bindings: bindings}))],
|
||||||
extraBindings));
|
extraBindings));
|
||||||
|
|
||||||
expect(inj.get('injectable2')).toEqual('injectable1-injectable2');
|
expect(inj.get('injectable2')).toEqual('injectable1-injectable2');
|
||||||
|
@ -642,7 +641,7 @@ export function main() {
|
||||||
|
|
||||||
|
|
||||||
var inj = injector(ListWrapper.concat(
|
var inj = injector(ListWrapper.concat(
|
||||||
[DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
|
[DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
|
||||||
viewBindings: viewBindings}))], extraBindings),
|
viewBindings: viewBindings}))], extraBindings),
|
||||||
null, true);
|
null, true);
|
||||||
expect(inj.get('injectable2')).toEqual('injectable1-injectable2');
|
expect(inj.get('injectable2')).toEqual('injectable1-injectable2');
|
||||||
|
@ -650,7 +649,7 @@ export function main() {
|
||||||
|
|
||||||
it("should instantiate components that depend on viewBindings bindings", () => {
|
it("should instantiate components that depend on viewBindings bindings", () => {
|
||||||
var inj = injector(
|
var inj = injector(
|
||||||
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new dirAnn.Component({
|
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new ComponentMetadata({
|
||||||
viewBindings: [bind('service').toValue('service')]
|
viewBindings: [bind('service').toValue('service')]
|
||||||
}))],
|
}))],
|
||||||
extraBindings),
|
extraBindings),
|
||||||
|
@ -661,7 +660,7 @@ export function main() {
|
||||||
it("should instantiate bindings lazily", () => {
|
it("should instantiate bindings lazily", () => {
|
||||||
var created = false;
|
var created = false;
|
||||||
var inj = injector(
|
var inj = injector(
|
||||||
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
|
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
|
||||||
bindings: [bind('service').toFactory(() => created = true)]
|
bindings: [bind('service').toFactory(() => created = true)]
|
||||||
}))],
|
}))],
|
||||||
extraBindings),
|
extraBindings),
|
||||||
|
@ -677,7 +676,7 @@ export function main() {
|
||||||
it("should instantiate view bindings lazily", () => {
|
it("should instantiate view bindings lazily", () => {
|
||||||
var created = false;
|
var created = false;
|
||||||
var inj = injector(
|
var inj = injector(
|
||||||
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
|
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
|
||||||
viewBindings: [bind('service').toFactory(() => created = true)]
|
viewBindings: [bind('service').toFactory(() => created = true)]
|
||||||
}))],
|
}))],
|
||||||
extraBindings),
|
extraBindings),
|
||||||
|
@ -692,7 +691,7 @@ export function main() {
|
||||||
|
|
||||||
it("should not instantiate other directives that depend on viewBindings bindings",
|
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)
|
viewBindings: ListWrapper.concat([bind("service").toValue("service")], extraBindings)
|
||||||
});
|
});
|
||||||
var componentDirective =
|
var componentDirective =
|
||||||
|
@ -704,7 +703,7 @@ export function main() {
|
||||||
|
|
||||||
it("should instantiate directives that depend on bindings bindings of other directives", () => {
|
it("should instantiate directives that depend on bindings bindings of other directives", () => {
|
||||||
var shadowInj = hostShadowInjectors(
|
var shadowInj = hostShadowInjectors(
|
||||||
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component({
|
ListWrapper.concat([DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata({
|
||||||
bindings: [bind('service').toValue('hostService')]})
|
bindings: [bind('service').toValue('hostService')]})
|
||||||
)], extraBindings),
|
)], extraBindings),
|
||||||
ListWrapper.concat([NeedsService], extraBindings)
|
ListWrapper.concat([NeedsService], extraBindings)
|
||||||
|
@ -742,7 +741,7 @@ export function main() {
|
||||||
|
|
||||||
it("should prioritize viewBindings over bindings for the same binding", () => {
|
it("should prioritize viewBindings over bindings for the same binding", () => {
|
||||||
var inj = injector(
|
var inj = injector(
|
||||||
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new dirAnn.Component({
|
ListWrapper.concat([DirectiveBinding.createFromType(NeedsService, new ComponentMetadata({
|
||||||
bindings: [bind('service').toValue('hostService')],
|
bindings: [bind('service').toValue('hostService')],
|
||||||
viewBindings: [bind('service').toValue('viewService')]})
|
viewBindings: [bind('service').toValue('viewService')]})
|
||||||
)], extraBindings), null, true);
|
)], extraBindings), null, true);
|
||||||
|
@ -755,7 +754,7 @@ export function main() {
|
||||||
hostShadowInjectors(
|
hostShadowInjectors(
|
||||||
ListWrapper.concat([
|
ListWrapper.concat([
|
||||||
SimpleDirective,
|
SimpleDirective,
|
||||||
DirectiveBinding.createFromType(SomeOtherDirective, new dirAnn.Directive({
|
DirectiveBinding.createFromType(SomeOtherDirective, new DirectiveMetadata({
|
||||||
bindings: [bind('service').toValue('hostService')]})
|
bindings: [bind('service').toValue('hostService')]})
|
||||||
)], extraBindings),
|
)], extraBindings),
|
||||||
|
|
||||||
|
@ -827,7 +826,7 @@ export function main() {
|
||||||
|
|
||||||
it("should instantiate directives that depend on the containing component", () => {
|
it("should instantiate directives that depend on the containing component", () => {
|
||||||
var directiveBinding =
|
var directiveBinding =
|
||||||
DirectiveBinding.createFromType(SimpleDirective, new dirAnn.Component());
|
DirectiveBinding.createFromType(SimpleDirective, new ComponentMetadata());
|
||||||
var shadow = hostShadowInjectors(ListWrapper.concat([directiveBinding], extraBindings),
|
var shadow = hostShadowInjectors(ListWrapper.concat([directiveBinding], extraBindings),
|
||||||
[NeeedsDirectiveFromHost]);
|
[NeeedsDirectiveFromHost]);
|
||||||
|
|
||||||
|
@ -839,7 +838,7 @@ export function main() {
|
||||||
it("should not instantiate directives that depend on other directives in the containing component's ElementInjector",
|
it("should not instantiate directives that depend on other directives in the containing component's ElementInjector",
|
||||||
() => {
|
() => {
|
||||||
var directiveBinding =
|
var directiveBinding =
|
||||||
DirectiveBinding.createFromType(SomeOtherDirective, new dirAnn.Component());
|
DirectiveBinding.createFromType(SomeOtherDirective, new ComponentMetadata());
|
||||||
expect(() =>
|
expect(() =>
|
||||||
{
|
{
|
||||||
hostShadowInjectors(
|
hostShadowInjectors(
|
||||||
|
@ -855,7 +854,7 @@ export function main() {
|
||||||
it("should call onDestroy on directives subscribed to this event", () => {
|
it("should call onDestroy on directives subscribed to this event", () => {
|
||||||
var inj = injector(ListWrapper.concat(
|
var inj = injector(ListWrapper.concat(
|
||||||
[DirectiveBinding.createFromType(DirectiveWithDestroy,
|
[DirectiveBinding.createFromType(DirectiveWithDestroy,
|
||||||
new dirAnn.Directive({lifecycle: [LifecycleEvent.onDestroy]}))],
|
new DirectiveMetadata({lifecycle: [LifecycleEvent.onDestroy]}))],
|
||||||
extraBindings));
|
extraBindings));
|
||||||
var destroy = inj.get(DirectiveWithDestroy);
|
var destroy = inj.get(DirectiveWithDestroy);
|
||||||
inj.dehydrate();
|
inj.dehydrate();
|
||||||
|
@ -865,7 +864,7 @@ export function main() {
|
||||||
it("should work with services", () => {
|
it("should work with services", () => {
|
||||||
var inj = injector(ListWrapper.concat(
|
var inj = injector(ListWrapper.concat(
|
||||||
[DirectiveBinding.createFromType(
|
[DirectiveBinding.createFromType(
|
||||||
SimpleDirective, new dirAnn.Directive({bindings: [SimpleService]}))],
|
SimpleDirective, new DirectiveMetadata({bindings: [SimpleService]}))],
|
||||||
extraBindings));
|
extraBindings));
|
||||||
inj.dehydrate();
|
inj.dehydrate();
|
||||||
});
|
});
|
||||||
|
@ -942,7 +941,7 @@ export function main() {
|
||||||
var childView = new DummyView();
|
var childView = new DummyView();
|
||||||
childView.changeDetector = cd;
|
childView.changeDetector = cd;
|
||||||
view.spy('getNestedView').andReturn(childView);
|
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,
|
var inj = injector(ListWrapper.concat([binding], extraBindings), null, true,
|
||||||
new PreBuiltObjects(null, view, <any>new DummyElementRef(), null));
|
new PreBuiltObjects(null, view, <any>new DummyElementRef(), null));
|
||||||
|
|
||||||
|
@ -953,7 +952,7 @@ export function main() {
|
||||||
var cd = new DynamicChangeDetector(null, null, null, [], [], []);
|
var cd = new DynamicChangeDetector(null, null, null, [], [], []);
|
||||||
var view = <any>new DummyView();
|
var view = <any>new DummyView();
|
||||||
view.changeDetector =cd;
|
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,
|
var inj = injector(ListWrapper.concat([binding], extraBindings), null, false,
|
||||||
new PreBuiltObjects(null, view, <any>new DummyElementRef(), null));
|
new PreBuiltObjects(null, view, <any>new DummyElementRef(), null));
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,7 @@ import {
|
||||||
ON_PUSH
|
ON_PUSH
|
||||||
} from 'angular2/src/change_detection/change_detection';
|
} from 'angular2/src/change_detection/change_detection';
|
||||||
|
|
||||||
import {Directive, Component, View, Attribute, Query, Pipe} from 'angular2/annotations';
|
import {Directive, Component, View, ViewMetadata, Attribute, Query, Pipe} from 'angular2/metadata';
|
||||||
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
|
|
||||||
|
|
||||||
import {QueryList} from 'angular2/src/core/compiler/query_list';
|
import {QueryList} from 'angular2/src/core/compiler/query_list';
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ export function main() {
|
||||||
describe('react to record changes', function() {
|
describe('react to record changes', function() {
|
||||||
it('should consume text node changes',
|
it('should consume text node changes',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
rootTC.componentInstance.ctxProp = 'Hello World!';
|
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',
|
it('should update text node with a blank string when interpolation evaluates to null',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
rootTC.componentInstance.ctxProp = null;
|
rootTC.componentInstance.ctxProp = null;
|
||||||
|
@ -116,7 +115,7 @@ export function main() {
|
||||||
|
|
||||||
it('should consume element binding changes',
|
it('should consume element binding changes',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
|
||||||
|
@ -131,7 +130,7 @@ export function main() {
|
||||||
it('should consume binding to aria-* attributes',
|
it('should consume binding to aria-* attributes',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp,
|
tcb.overrideView(MyComp,
|
||||||
new viewAnn.View({template: '<div [attr.aria-label]="ctxProp"></div>'}))
|
new ViewMetadata({template: '<div [attr.aria-label]="ctxProp"></div>'}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.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',
|
it('should consume binding to property names where attr name and property name do not match',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp,
|
tcb.overrideView(MyComp,
|
||||||
new viewAnn.View({template: '<div [tabindex]="ctxNumProp"></div>'}))
|
new ViewMetadata({template: '<div [tabindex]="ctxNumProp"></div>'}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -174,7 +173,7 @@ export function main() {
|
||||||
it('should consume binding to camel-cased properties using dash-cased syntax in templates',
|
it('should consume binding to camel-cased properties using dash-cased syntax in templates',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp,
|
tcb.overrideView(MyComp,
|
||||||
new viewAnn.View({template: '<input [read-only]="ctxBoolProp">'}))
|
new ViewMetadata({template: '<input [read-only]="ctxBoolProp">'}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -193,7 +192,7 @@ export function main() {
|
||||||
it('should consume binding to inner-html',
|
it('should consume binding to inner-html',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp,
|
tcb.overrideView(MyComp,
|
||||||
new viewAnn.View({template: '<div inner-html="{{ctxProp}}"></div>'}))
|
new ViewMetadata({template: '<div inner-html="{{ctxProp}}"></div>'}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -216,7 +215,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View({template: '<div class="initial" [class]="ctxProp"></div>'}))
|
new ViewMetadata({template: '<div class="initial" [class]="ctxProp"></div>'}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -240,7 +239,7 @@ export function main() {
|
||||||
'<div my-dir elprop="Hi {{\'there!\'}}"></div>' +
|
'<div my-dir elprop="Hi {{\'there!\'}}"></div>' +
|
||||||
'<div my-dir elprop="One more {{ctxProp}}"></div>' +
|
'<div my-dir elprop="One more {{ctxProp}}"></div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({template: tpl, directives: [MyDir]}))
|
tcb.overrideView(MyComp, new ViewMetadata({template: tpl, directives: [MyDir]}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -260,9 +259,10 @@ export function main() {
|
||||||
|
|
||||||
describe('pipes', () => {
|
describe('pipes', () => {
|
||||||
it("should support pipes in bindings",
|
it("should support pipes in bindings",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject(
|
||||||
(tcb: TestComponentBuilder, async) => {
|
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template: '<div my-dir #dir="mydir" [elprop]="ctxProp | double"></div>',
|
template: '<div my-dir #dir="mydir" [elprop]="ctxProp | double"></div>',
|
||||||
directives: [MyDir],
|
directives: [MyDir],
|
||||||
pipes: [DoublePipe]
|
pipes: [DoublePipe]
|
||||||
|
@ -284,7 +284,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View({template: '<child-cmp></child-cmp>', directives: [ChildComp]}))
|
new ViewMetadata({template: '<child-cmp></child-cmp>', directives: [ChildComp]}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -299,7 +299,7 @@ export function main() {
|
||||||
// GH issue 328 - https://github.com/angular/angular/issues/328
|
// GH issue 328 - https://github.com/angular/angular/issues/328
|
||||||
it('should support different directive types on a single node',
|
it('should support different directive types on a single node',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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>',
|
template: '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>',
|
||||||
directives: [MyDir, ChildComp]
|
directives: [MyDir, ChildComp]
|
||||||
}))
|
}))
|
||||||
|
@ -321,7 +321,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support directives where a binding attribute is not given',
|
it('should support directives where a binding attribute is not given',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
// No attribute "el-prop" specified.
|
// No attribute "el-prop" specified.
|
||||||
template: '<p my-dir></p>',
|
template: '<p my-dir></p>',
|
||||||
directives: [MyDir]
|
directives: [MyDir]
|
||||||
|
@ -333,7 +333,8 @@ export function main() {
|
||||||
|
|
||||||
it('should execute a given directive once, even if specified multiple times',
|
it('should execute a given directive once, even if specified multiple times',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template: '<p no-duplicate></p>',
|
template: '<p no-duplicate></p>',
|
||||||
directives: [
|
directives: [
|
||||||
DuplicateDir,
|
DuplicateDir,
|
||||||
|
@ -350,7 +351,7 @@ export function main() {
|
||||||
|
|
||||||
it('should use the last directive binding per directive',
|
it('should use the last directive binding per directive',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<p no-duplicate></p>',
|
template: '<p no-duplicate></p>',
|
||||||
directives: [
|
directives: [
|
||||||
bind(DuplicateDir)
|
bind(DuplicateDir)
|
||||||
|
@ -367,7 +368,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support directives where a selector matches property binding',
|
it('should support directives where a selector matches property binding',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View(
|
tcb.overrideView(MyComp, new ViewMetadata(
|
||||||
{template: '<p [id]="ctxProp"></p>', directives: [IdDir]}))
|
{template: '<p [id]="ctxProp"></p>', directives: [IdDir]}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
|
@ -389,7 +390,7 @@ export function main() {
|
||||||
|
|
||||||
it('should allow specifying directives as bindings',
|
it('should allow specifying directives as bindings',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<child-cmp></child-cmp>',
|
template: '<child-cmp></child-cmp>',
|
||||||
directives: [bind(ChildComp).toClass(ChildComp)]
|
directives: [bind(ChildComp).toClass(ChildComp)]
|
||||||
}))
|
}))
|
||||||
|
@ -405,7 +406,7 @@ export function main() {
|
||||||
|
|
||||||
it('should read directives metadata from their binding token',
|
it('should read directives metadata from their binding token',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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>',
|
template: '<div public-api><div needs-public-api></div></div>',
|
||||||
directives: [bind(PublicApi).toClass(PrivateImpl), NeedsPublicApi]
|
directives: [bind(PublicApi).toClass(PrivateImpl), NeedsPublicApi]
|
||||||
}))
|
}))
|
||||||
|
@ -416,7 +417,8 @@ export function main() {
|
||||||
|
|
||||||
it('should support template directives via `<template>` elements.',
|
it('should support template directives via `<template>` elements.',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template:
|
template:
|
||||||
'<div><template some-viewport var-greeting="some-tmpl"><copy-me>{{greeting}}</copy-me></template></div>',
|
'<div><template some-viewport var-greeting="some-tmpl"><copy-me>{{greeting}}</copy-me></template></div>',
|
||||||
directives: [SomeViewport]
|
directives: [SomeViewport]
|
||||||
|
@ -438,7 +440,8 @@ export function main() {
|
||||||
|
|
||||||
it('should support template directives via `template` attribute.',
|
it('should support template directives via `template` attribute.',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template:
|
template:
|
||||||
'<div><copy-me template="some-viewport: var greeting=some-tmpl">{{greeting}}</copy-me></div>',
|
'<div><copy-me template="some-viewport: var greeting=some-tmpl">{{greeting}}</copy-me></div>',
|
||||||
directives: [SomeViewport]
|
directives: [SomeViewport]
|
||||||
|
@ -459,7 +462,8 @@ export function main() {
|
||||||
|
|
||||||
it('should allow to transplant embedded ProtoViews into other ViewContainers',
|
it('should allow to transplant embedded ProtoViews into other ViewContainers',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template:
|
template:
|
||||||
'<some-directive><toolbar><template toolbarpart var-toolbar-prop="toolbarProp">{{ctxProp}},{{toolbarProp}},<cmp-with-host></cmp-with-host></template></toolbar></some-directive>',
|
'<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]
|
directives: [SomeDirective, CompWithHost, ToolbarComponent, ToolbarPart]
|
||||||
|
@ -480,8 +484,8 @@ export function main() {
|
||||||
describe("variable bindings", () => {
|
describe("variable bindings", () => {
|
||||||
it('should assign a component to a var-',
|
it('should assign a component to a var-',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder,
|
(tcb: TestComponentBuilder, async) => {
|
||||||
async) => {tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<p><child-cmp var-alice></child-cmp></p>',
|
template: '<p><child-cmp var-alice></child-cmp></p>',
|
||||||
directives: [ChildComp]
|
directives: [ChildComp]
|
||||||
}))
|
}))
|
||||||
|
@ -497,7 +501,7 @@ export function main() {
|
||||||
it('should assign a directive to a var-',
|
it('should assign a directive to a var-',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<p><div export-dir #localdir="dir"></div></p>',
|
template: '<p><div export-dir #localdir="dir"></div></p>',
|
||||||
directives: [ExportDir]
|
directives: [ExportDir]
|
||||||
}))
|
}))
|
||||||
|
@ -512,9 +516,11 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should make the assigned component accessible in property bindings',
|
it('should make the assigned component accessible in property bindings',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject(
|
||||||
|
[TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(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>',
|
template: '<p><child-cmp var-alice></child-cmp>{{alice.ctxProp}}</p>',
|
||||||
directives: [ChildComp]
|
directives: [ChildComp]
|
||||||
}))
|
}))
|
||||||
|
@ -531,9 +537,11 @@ export function main() {
|
||||||
})}));
|
})}));
|
||||||
|
|
||||||
it('should assign two component instances each with a var-',
|
it('should assign two component instances each with a var-',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject(
|
||||||
|
[TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(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>',
|
template: '<p><child-cmp var-alice></child-cmp><child-cmp var-bob></p>',
|
||||||
directives: [ChildComp]
|
directives: [ChildComp]
|
||||||
}))
|
}))
|
||||||
|
@ -554,7 +562,7 @@ export function main() {
|
||||||
it('should assign the component instance to a var- with shorthand syntax',
|
it('should assign the component instance to a var- with shorthand syntax',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder,
|
(tcb: TestComponentBuilder,
|
||||||
async) => {tcb.overrideView(MyComp, new viewAnn.View({
|
async) => {tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<child-cmp #alice></child-cmp>',
|
template: '<child-cmp #alice></child-cmp>',
|
||||||
directives: [ChildComp]
|
directives: [ChildComp]
|
||||||
}))
|
}))
|
||||||
|
@ -572,7 +580,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp,
|
tcb.overrideView(MyComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<p><div var-alice><i>Hello</i></div></p>'}))
|
{template: '<p><div var-alice><i>Hello</i></div></p>'}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
|
@ -588,7 +596,7 @@ export function main() {
|
||||||
it('should change dash-case to camel-case',
|
it('should change dash-case to camel-case',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<p><child-cmp var-super-alice></child-cmp></p>',
|
template: '<p><child-cmp var-super-alice></child-cmp></p>',
|
||||||
directives: [ChildComp]
|
directives: [ChildComp]
|
||||||
}))
|
}))
|
||||||
|
@ -605,7 +613,8 @@ export function main() {
|
||||||
it('should allow to use variables in a for loop',
|
it('should allow to use variables in a for loop',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
|
||||||
async) => {
|
async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template:
|
template:
|
||||||
'<div><div *ng-for="var i of [1]"><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</div></div>',
|
'<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]
|
directives: [ChildCompNoTemplate, NgFor]
|
||||||
|
@ -628,7 +637,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
|
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>',
|
template: '<push-cmp-with-ref #cmp></push-cmp-with-ref>',
|
||||||
directives: [[[PushCmpWithRef]]]
|
directives: [[[PushCmpWithRef]]]
|
||||||
}))
|
}))
|
||||||
|
@ -655,7 +664,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
|
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
|
template: '<push-cmp [prop]="ctxProp" #cmp></push-cmp>',
|
||||||
directives: [[[PushCmp]]]
|
directives: [[[PushCmp]]]
|
||||||
}))
|
}))
|
||||||
|
@ -676,11 +685,12 @@ export function main() {
|
||||||
})}));
|
})}));
|
||||||
|
|
||||||
it('should not affect updating properties on the component',
|
it('should not affect updating properties on the component',
|
||||||
inject(
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
[TestComponentBuilder, AsyncTestCompleter],
|
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
template: '<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
|
MyComp, new ViewMetadata({
|
||||||
|
template:
|
||||||
|
'<push-cmp-with-ref [prop]="ctxProp" #cmp></push-cmp-with-ref>',
|
||||||
directives: [[[PushCmpWithRef]]]
|
directives: [[[PushCmpWithRef]]]
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -703,7 +713,8 @@ export function main() {
|
||||||
if (DOM.supportsDOMEvents()) {
|
if (DOM.supportsDOMEvents()) {
|
||||||
it('should be checked when an async pipe requests a check',
|
it('should be checked when an async pipe requests a check',
|
||||||
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
|
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>',
|
template: '<push-cmp-with-async #cmp></push-cmp-with-async>',
|
||||||
directives: [[[PushCmpWithAsyncPipe]]]
|
directives: [[[PushCmpWithAsyncPipe]]]
|
||||||
}));
|
}));
|
||||||
|
@ -732,7 +743,7 @@ export function main() {
|
||||||
it('should create a component that injects an @Host',
|
it('should create a component that injects an @Host',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<some-directive>
|
<some-directive>
|
||||||
<p>
|
<p>
|
||||||
|
@ -753,7 +764,7 @@ export function main() {
|
||||||
|
|
||||||
it('should create a component that injects an @Host through viewcontainer directive',
|
it('should create a component that injects an @Host through viewcontainer directive',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<some-directive>
|
<some-directive>
|
||||||
<p *ng-if="true">
|
<p *ng-if="true">
|
||||||
|
@ -778,7 +789,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support events via EventEmitter',
|
it('should support events via EventEmitter',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div emitter listener></div>',
|
template: '<div emitter listener></div>',
|
||||||
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
|
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
|
||||||
}))
|
}))
|
||||||
|
@ -803,7 +814,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support [()] syntax',
|
it('should support [()] syntax',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div [(control)]="ctxProp" two-way></div>',
|
template: '<div [(control)]="ctxProp" two-way></div>',
|
||||||
directives: [DirectiveWithTwoWayBinding]
|
directives: [DirectiveWithTwoWayBinding]
|
||||||
}))
|
}))
|
||||||
|
@ -831,7 +842,7 @@ export function main() {
|
||||||
it("should support invoking methods on the host element via hostActions",
|
it("should support invoking methods on the host element via hostActions",
|
||||||
inject(
|
inject(
|
||||||
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div update-host-actions></div>',
|
template: '<div update-host-actions></div>',
|
||||||
directives: [DirectiveUpdatingHostActions]
|
directives: [DirectiveUpdatingHostActions]
|
||||||
}))
|
}))
|
||||||
|
@ -856,7 +867,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<div listener></div>', directives: [DirectiveListeningDomEvent]}))
|
{template: '<div listener></div>', directives: [DirectiveListeningDomEvent]}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
|
@ -877,7 +888,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<div listener></div>', directives: [DirectiveListeningDomEvent]}))
|
{template: '<div listener></div>', directives: [DirectiveListeningDomEvent]}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
|
@ -902,7 +913,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support updating host element via hostAttributes',
|
it('should support updating host element via hostAttributes',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div update-host-attributes></div>',
|
template: '<div update-host-attributes></div>',
|
||||||
directives: [DirectiveUpdatingHostAttributes]
|
directives: [DirectiveUpdatingHostAttributes]
|
||||||
}))
|
}))
|
||||||
|
@ -920,7 +931,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support updating host element via hostProperties',
|
it('should support updating host element via hostProperties',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div update-host-properties></div>',
|
template: '<div update-host-properties></div>',
|
||||||
directives: [DirectiveUpdatingHostProperties]
|
directives: [DirectiveUpdatingHostProperties]
|
||||||
}))
|
}))
|
||||||
|
@ -945,11 +956,14 @@ export function main() {
|
||||||
it('should support preventing default on render events',
|
it('should support preventing default on render events',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder,
|
||||||
async) => {
|
async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template:
|
template:
|
||||||
'<input type="checkbox" listenerprevent></input><input type="checkbox" listenernoprevent></input>',
|
'<input type="checkbox" listenerprevent></input><input type="checkbox" listenernoprevent></input>',
|
||||||
directives:
|
directives: [
|
||||||
[DirectiveListeningDomEventPrevent, DirectiveListeningDomEventNoPrevent]
|
DirectiveListeningDomEventPrevent,
|
||||||
|
DirectiveListeningDomEventNoPrevent
|
||||||
|
]
|
||||||
}))
|
}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
|
@ -973,9 +987,11 @@ export function main() {
|
||||||
|
|
||||||
it('should support render global events from multiple directives',
|
it('should support render global events from multiple directives',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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>',
|
template: '<div *ng-if="ctxBoolProp" listener listenerother></div>',
|
||||||
directives: [NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
|
directives:
|
||||||
|
[NgIf, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
|
||||||
}))
|
}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
|
@ -1013,7 +1029,7 @@ export function main() {
|
||||||
it('should allow to create a ViewContainerRef at any bound location',
|
it('should allow to create a ViewContainerRef at any bound location',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter, Compiler],
|
inject([TestComponentBuilder, AsyncTestCompleter, Compiler],
|
||||||
(tcb: TestComponentBuilder, async, compiler) => {
|
(tcb: TestComponentBuilder, async, compiler) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',
|
template: '<div><dynamic-vp #dynamic></dynamic-vp></div>',
|
||||||
directives: [DynamicViewport]
|
directives: [DynamicViewport]
|
||||||
}))
|
}))
|
||||||
|
@ -1037,7 +1053,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<input static type="text" title>', directives: [NeedsAttribute]}))
|
{template: '<input static type="text" title>', directives: [NeedsAttribute]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -1055,7 +1071,8 @@ export function main() {
|
||||||
describe("dependency injection", () => {
|
describe("dependency injection", () => {
|
||||||
it("should support bindings",
|
it("should support bindings",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<directive-providing-injectable >
|
<directive-providing-injectable >
|
||||||
<directive-consuming-injectable #consuming>
|
<directive-consuming-injectable #consuming>
|
||||||
|
@ -1075,7 +1092,7 @@ export function main() {
|
||||||
|
|
||||||
it("should support viewBindings",
|
it("should support viewBindings",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(DirectiveProvidingInjectableInView, new viewAnn.View({
|
tcb.overrideView(DirectiveProvidingInjectableInView, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<directive-consuming-injectable #consuming>
|
<directive-consuming-injectable #consuming>
|
||||||
</directive-consuming-injectable>
|
</directive-consuming-injectable>
|
||||||
|
@ -1093,7 +1110,7 @@ export function main() {
|
||||||
|
|
||||||
it("should support unbounded lookup",
|
it("should support unbounded lookup",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<directive-providing-injectable>
|
<directive-providing-injectable>
|
||||||
<directive-containing-directive-consuming-an-injectable #dir>
|
<directive-containing-directive-consuming-an-injectable #dir>
|
||||||
|
@ -1105,7 +1122,7 @@ export function main() {
|
||||||
DirectiveContainingDirectiveConsumingAnInjectable
|
DirectiveContainingDirectiveConsumingAnInjectable
|
||||||
]
|
]
|
||||||
}))
|
}))
|
||||||
.overrideView(DirectiveContainingDirectiveConsumingAnInjectable, new viewAnn.View({
|
.overrideView(DirectiveContainingDirectiveConsumingAnInjectable, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<directive-consuming-injectable-unbounded></directive-consuming-injectable-unbounded>
|
<directive-consuming-injectable-unbounded></directive-consuming-injectable-unbounded>
|
||||||
`,
|
`,
|
||||||
|
@ -1123,7 +1140,7 @@ export function main() {
|
||||||
|
|
||||||
it("should support the event-bus scenario",
|
it("should support the event-bus scenario",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<grand-parent-providing-event-bus>
|
<grand-parent-providing-event-bus>
|
||||||
<parent-providing-event-bus>
|
<parent-providing-event-bus>
|
||||||
|
@ -1159,7 +1176,8 @@ export function main() {
|
||||||
|
|
||||||
it("should instantiate bindings lazily",
|
it("should instantiate bindings lazily",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MyComp, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<component-providing-logging-injectable #providing>
|
<component-providing-logging-injectable #providing>
|
||||||
<directive-consuming-injectable *ng-if="ctxBoolProp">
|
<directive-consuming-injectable *ng-if="ctxBoolProp">
|
||||||
|
@ -1187,7 +1205,7 @@ export function main() {
|
||||||
describe("corner cases", () => {
|
describe("corner cases", () => {
|
||||||
it('should remove script tags from templates',
|
it('should remove script tags from templates',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: `
|
template: `
|
||||||
<script>alert("Ooops");</script>
|
<script>alert("Ooops");</script>
|
||||||
<div>before<script>alert("Ooops");</script><span>inside</span>after</div>`
|
<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',
|
it('should report a meaningful error when a directive is missing annotation',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb = tcb.overrideView(MyComp,
|
tcb = tcb.overrideView(MyComp,
|
||||||
new viewAnn.View({directives: [SomeDirectiveMissingAnnotation]}));
|
new ViewMetadata({directives: [SomeDirectiveMissingAnnotation]}));
|
||||||
|
|
||||||
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
|
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
|
||||||
expect(e.message).toEqual(
|
expect(e.message).toEqual(
|
||||||
|
@ -1227,7 +1245,7 @@ export function main() {
|
||||||
it('should report a meaningful error when a directive is null',
|
it('should report a meaningful error when a directive is null',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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) => {
|
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
|
||||||
expect(e.message).toEqual(
|
expect(e.message).toEqual(
|
||||||
|
@ -1240,7 +1258,8 @@ export function main() {
|
||||||
it('should provide an error context when an error happens in DI',
|
it('should provide an error context when an error happens in DI',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
|
|
||||||
tcb = tcb.overrideView(MyComp, new viewAnn.View({
|
tcb =
|
||||||
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
directives: [DirectiveThrowingAnError],
|
directives: [DirectiveThrowingAnError],
|
||||||
template: `<directive-throwing-error></<directive-throwing-error>`
|
template: `<directive-throwing-error></<directive-throwing-error>`
|
||||||
}));
|
}));
|
||||||
|
@ -1259,7 +1278,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
|
|
||||||
tcb = tcb.overrideView(
|
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 => {
|
tcb.createAsync(MyComp).then(rootTC => {
|
||||||
try {
|
try {
|
||||||
|
@ -1282,7 +1301,7 @@ export function main() {
|
||||||
it('should provide an error context when an error happens in change detection (text node)',
|
it('should provide an error context when an error happens in change detection (text node)',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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 => {
|
tcb.createAsync(MyComp).then(rootTC => {
|
||||||
try {
|
try {
|
||||||
|
@ -1302,7 +1321,8 @@ export function main() {
|
||||||
it('should provide an error context when an error happens in an event handler',
|
it('should provide an error context when an error happens in an event handler',
|
||||||
inject([TestComponentBuilder], fakeAsync((tcb: TestComponentBuilder) => {
|
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>`,
|
template: `<span emitter listener (event)="throwError()" #local></span>`,
|
||||||
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
|
directives: [DirectiveEmitingEvent, DirectiveListeningEvent]
|
||||||
}));
|
}));
|
||||||
|
@ -1337,7 +1357,7 @@ export function main() {
|
||||||
|
|
||||||
var undefinedValue;
|
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) => {
|
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
|
||||||
expect(e.message).toEqual(
|
expect(e.message).toEqual(
|
||||||
|
@ -1352,7 +1372,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
|
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({template: '{{a.b}}'}))
|
tcb.overrideView(MyComp, new ViewMetadata({template: '{{a.b}}'}))
|
||||||
|
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -1366,7 +1386,7 @@ export function main() {
|
||||||
[TestComponentBuilder, AsyncTestCompleter],
|
[TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(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)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
|
@ -1379,7 +1399,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter],
|
inject([TestComponentBuilder, AsyncTestCompleter],
|
||||||
(tcb: TestComponentBuilder, async) => {
|
(tcb: TestComponentBuilder, async) => {
|
||||||
|
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<child-cmp [title]="a.b"></child-cmp>',
|
template: '<child-cmp [title]="a.b"></child-cmp>',
|
||||||
directives: [ChildComp]
|
directives: [ChildComp]
|
||||||
}))
|
}))
|
||||||
|
@ -1394,7 +1414,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support imperative views',
|
it('should support imperative views',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<simple-imp-cmp></simple-imp-cmp>',
|
template: '<simple-imp-cmp></simple-imp-cmp>',
|
||||||
directives: [SimpleImperativeViewComponent]
|
directives: [SimpleImperativeViewComponent]
|
||||||
}))
|
}))
|
||||||
|
@ -1406,9 +1426,9 @@ export function main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should support moving embedded views around',
|
it('should support moving embedded views around',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter, ANCHOR_ELEMENT],
|
inject([TestComponentBuilder, AsyncTestCompleter, ANCHOR_ELEMENT], (tcb, async,
|
||||||
(tcb, async, anchorElement) => {
|
anchorElement) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<div><div *some-impvp="ctxBoolProp">hello</div></div>',
|
template: '<div><div *some-impvp="ctxBoolProp">hello</div></div>',
|
||||||
directives: [SomeImperativeViewport]
|
directives: [SomeImperativeViewport]
|
||||||
}))
|
}))
|
||||||
|
@ -1437,7 +1457,7 @@ export function main() {
|
||||||
async) => {
|
async) => {
|
||||||
tcb =
|
tcb =
|
||||||
tcb.overrideView(MyComp,
|
tcb.overrideView(MyComp,
|
||||||
new viewAnn.View({template: '<div unknown="{{ctxProp}}"></div>'}))
|
new ViewMetadata({template: '<div unknown="{{ctxProp}}"></div>'}))
|
||||||
|
|
||||||
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
|
PromiseWrapper.catchError(tcb.createAsync(MyComp), (e) => {
|
||||||
expect(e.message).toEqual(
|
expect(e.message).toEqual(
|
||||||
|
@ -1452,7 +1472,7 @@ export function main() {
|
||||||
async) => {
|
async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View(
|
new ViewMetadata(
|
||||||
{template: '<div my-dir [elprop]="ctxProp"></div>', directives: [MyDir]}))
|
{template: '<div my-dir [elprop]="ctxProp"></div>', directives: [MyDir]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((val) => { async.done(); });
|
.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',
|
it('should not be created when there is a directive with the same property',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<span [title]="ctxProp"></span>',
|
template: '<span [title]="ctxProp"></span>',
|
||||||
directives: [DirectiveWithTitle]
|
directives: [DirectiveWithTitle]
|
||||||
}))
|
}))
|
||||||
|
@ -1480,7 +1500,7 @@ export function main() {
|
||||||
|
|
||||||
it('should work when a directive uses hostProperty to update the DOM element',
|
it('should work when a directive uses hostProperty to update the DOM element',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp, new viewAnn.View({
|
tcb.overrideView(MyComp, new ViewMetadata({
|
||||||
template: '<span [title]="ctxProp"></span>',
|
template: '<span [title]="ctxProp"></span>',
|
||||||
directives: [DirectiveWithTitleAndHostProperty]
|
directives: [DirectiveWithTitleAndHostProperty]
|
||||||
}))
|
}))
|
||||||
|
@ -1504,7 +1524,7 @@ export function main() {
|
||||||
return inject(
|
return inject(
|
||||||
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MyComp,
|
tcb.overrideView(MyComp,
|
||||||
new viewAnn.View({template: `<!--${mode}--><div>{{ctxProp}}</div>`}))
|
new ViewMetadata({template: `<!--${mode}--><div>{{ctxProp}}</div>`}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((rootTC) => {
|
.then((rootTC) => {
|
||||||
rootTC.componentInstance.ctxProp = 'Hello World!';
|
rootTC.componentInstance.ctxProp = 'Hello World!';
|
||||||
|
@ -1526,7 +1546,7 @@ export function main() {
|
||||||
// - https://github.com/angular/angular/commit/81f3f32
|
// - https://github.com/angular/angular/commit/81f3f32
|
||||||
xdescribe('Missing directive checks', () => {
|
xdescribe('Missing directive checks', () => {
|
||||||
function expectCompileError(tcb, inlineTpl, errMessage, done) {
|
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(
|
PromiseWrapper.then(
|
||||||
tcb.createAsync(MyComp),
|
tcb.createAsync(MyComp),
|
||||||
(value) => {
|
(value) => {
|
||||||
|
|
|
@ -23,8 +23,6 @@ import {
|
||||||
|
|
||||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||||
|
|
||||||
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
Directive,
|
Directive,
|
||||||
|
@ -43,7 +41,7 @@ export function main() {
|
||||||
describe('projection', () => {
|
describe('projection', () => {
|
||||||
it('should support simple components',
|
it('should support simple components',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<simple>' +
|
template: '<simple>' +
|
||||||
'<div>A</div>' +
|
'<div>A</div>' +
|
||||||
'</simple>',
|
'</simple>',
|
||||||
|
@ -58,7 +56,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support simple components with text interpolation as direct children',
|
it('should support simple components with text interpolation as direct children',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '{{\'START(\'}}<simple>' +
|
template: '{{\'START(\'}}<simple>' +
|
||||||
'{{text}}' +
|
'{{text}}' +
|
||||||
'</simple>{{\')END\'}}',
|
'</simple>{{\')END\'}}',
|
||||||
|
@ -78,11 +76,10 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
Simple,
|
Simple,
|
||||||
new viewAnn.View(
|
new View(
|
||||||
{template: 'SIMPLE(<div><ng-content></ng-content></div>)', directives: []}))
|
{template: 'SIMPLE(<div><ng-content></ng-content></div>)', directives: []}))
|
||||||
.overrideView(
|
.overrideView(MainComp,
|
||||||
MainComp,
|
new View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
|
||||||
new viewAnn.View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
|
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.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',
|
it('should support projecting text interpolation to a non bound element with other bound elements after it',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(Simple, new viewAnn.View({
|
tcb.overrideView(
|
||||||
template: 'SIMPLE(<div><ng-content></ng-content></div><div [tab-index]="0">EL</div>)',
|
Simple, new View({
|
||||||
|
template:
|
||||||
|
'SIMPLE(<div><ng-content></ng-content></div><div [tab-index]="0">EL</div>)',
|
||||||
directives: []
|
directives: []
|
||||||
}))
|
}))
|
||||||
.overrideView(
|
.overrideView(MainComp,
|
||||||
MainComp,
|
new View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
|
||||||
new viewAnn.View({template: '<simple>{{text}}</simple>', directives: [Simple]}))
|
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
|
||||||
|
@ -115,8 +113,7 @@ export function main() {
|
||||||
|
|
||||||
it('should not show the light dom even if there is no content tag',
|
it('should not show the light dom even if there is no content tag',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp,
|
tcb.overrideView(MainComp, new View({template: '<empty>A</empty>', directives: [Empty]}))
|
||||||
new viewAnn.View({template: '<empty>A</empty>', directives: [Empty]}))
|
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
|
||||||
|
@ -127,7 +124,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support multiple content tags',
|
it('should support multiple content tags',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<multiple-content-tags>' +
|
template: '<multiple-content-tags>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
'<div>C</div>' +
|
'<div>C</div>' +
|
||||||
|
@ -145,7 +142,7 @@ export function main() {
|
||||||
|
|
||||||
it('should redistribute only direct children',
|
it('should redistribute only direct children',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<multiple-content-tags>' +
|
template: '<multiple-content-tags>' +
|
||||||
'<div>B<div class="left">A</div></div>' +
|
'<div>B<div class="left">A</div></div>' +
|
||||||
'<div>C</div>' +
|
'<div>C</div>' +
|
||||||
|
@ -162,7 +159,7 @@ export function main() {
|
||||||
|
|
||||||
it("should redistribute direct child viewcontainers when the light dom changes",
|
it("should redistribute direct child viewcontainers when the light dom changes",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<multiple-content-tags>' +
|
template: '<multiple-content-tags>' +
|
||||||
'<template manual class="left"><div>A1</div></template>' +
|
'<template manual class="left"><div>A1</div></template>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -188,7 +185,7 @@ export function main() {
|
||||||
|
|
||||||
it("should support nested components",
|
it("should support nested components",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<outer-with-indirect-nested>' +
|
template: '<outer-with-indirect-nested>' +
|
||||||
'<div>A</div>' +
|
'<div>A</div>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -205,7 +202,7 @@ export function main() {
|
||||||
|
|
||||||
it("should support nesting with content being direct child of a nested component",
|
it("should support nesting with content being direct child of a nested component",
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<outer>' +
|
template: '<outer>' +
|
||||||
'<template manual class="left"><div>A</div></template>' +
|
'<template manual class="left"><div>A</div></template>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -229,7 +226,7 @@ export function main() {
|
||||||
|
|
||||||
it('should redistribute when the shadow dom changes',
|
it('should redistribute when the shadow dom changes',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<conditional-content>' +
|
template: '<conditional-content>' +
|
||||||
'<div class="left">A</div>' +
|
'<div class="left">A</div>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -263,8 +260,7 @@ export function main() {
|
||||||
|
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MainComp,
|
MainComp,
|
||||||
new viewAnn.View(
|
new View({template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
||||||
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
|
||||||
.overrideTemplate(Simple, '<ng-content></ng-content><p>P,</p>{{stringProp}}')
|
.overrideTemplate(Simple, '<ng-content></ng-content><p>P,</p>{{stringProp}}')
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
@ -284,8 +280,7 @@ export function main() {
|
||||||
|
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MainComp,
|
MainComp,
|
||||||
new viewAnn.View(
|
new View({template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
||||||
{template: '<simple string-prop="text"></simple>', directives: [Simple]}))
|
|
||||||
.overrideTemplate(Simple, '<style></style><p>P,</p>{{stringProp}}')
|
.overrideTemplate(Simple, '<style></style><p>P,</p>{{stringProp}}')
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
@ -298,7 +293,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support moving non projected light dom around',
|
it('should support moving non projected light dom around',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<empty>' +
|
template: '<empty>' +
|
||||||
' <template manual><div>A</div></template>' +
|
' <template manual><div>A</div></template>' +
|
||||||
'</empty>' +
|
'</empty>' +
|
||||||
|
@ -323,7 +318,7 @@ export function main() {
|
||||||
|
|
||||||
it('should support moving projected light dom around',
|
it('should support moving projected light dom around',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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>' +
|
template: '<simple><template manual><div>A</div></template></simple>' +
|
||||||
'START(<div project></div>)END',
|
'START(<div project></div>)END',
|
||||||
directives: [Simple, ProjectDirective, ManualViewportDirective],
|
directives: [Simple, ProjectDirective, ManualViewportDirective],
|
||||||
|
@ -346,7 +341,8 @@ export function main() {
|
||||||
|
|
||||||
it('should support moving ng-content around',
|
it('should support moving ng-content around',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(
|
||||||
|
MainComp, new View({
|
||||||
template: '<conditional-content>' +
|
template: '<conditional-content>' +
|
||||||
'<div class="left">A</div>' +
|
'<div class="left">A</div>' +
|
||||||
'<div>B</div>' +
|
'<div>B</div>' +
|
||||||
|
@ -382,8 +378,7 @@ export function main() {
|
||||||
// the presence of ng-content elements!
|
// the presence of ng-content elements!
|
||||||
it('should still allow to implement a recursive trees',
|
it('should still allow to implement a recursive trees',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp,
|
tcb.overrideView(MainComp, new View({template: '<tree></tree>', directives: [Tree]}))
|
||||||
new viewAnn.View({template: '<tree></tree>', directives: [Tree]}))
|
|
||||||
.createAsync(MainComp)
|
.createAsync(MainComp)
|
||||||
.then((main) => {
|
.then((main) => {
|
||||||
|
|
||||||
|
@ -402,7 +397,7 @@ export function main() {
|
||||||
if (DOM.supportsNativeShadowDOM()) {
|
if (DOM.supportsNativeShadowDOM()) {
|
||||||
it('should support native content projection',
|
it('should support native content projection',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: '<simple-native>' +
|
template: '<simple-native>' +
|
||||||
'<div>A</div>' +
|
'<div>A</div>' +
|
||||||
'</simple-native>',
|
'</simple-native>',
|
||||||
|
@ -422,7 +417,7 @@ export function main() {
|
||||||
it('should support nested conditionals that contain ng-contents',
|
it('should support nested conditionals that contain ng-contents',
|
||||||
inject(
|
inject(
|
||||||
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
[TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(MainComp, new viewAnn.View({
|
tcb.overrideView(MainComp, new View({
|
||||||
template: `<conditional-text>a</conditional-text>`,
|
template: `<conditional-text>a</conditional-text>`,
|
||||||
directives: [ConditionalTextComponent]
|
directives: [ConditionalTextComponent]
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -29,11 +29,18 @@ import {
|
||||||
createDirectiveVariableBindings,
|
createDirectiveVariableBindings,
|
||||||
createVariableLocations
|
createVariableLocations
|
||||||
} from 'angular2/src/core/compiler/proto_view_factory';
|
} 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 {Key} from 'angular2/di';
|
||||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
||||||
import {DirectiveBinding} from 'angular2/src/core/compiler/element_injector';
|
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() {
|
export function main() {
|
||||||
// TODO(tbosch): add missing tests
|
// TODO(tbosch): add missing tests
|
||||||
|
@ -81,15 +88,15 @@ export function main() {
|
||||||
describe("createDirectiveVariableBindings", () => {
|
describe("createDirectiveVariableBindings", () => {
|
||||||
it("should calculate directive variable bindings", () => {
|
it("should calculate directive variable bindings", () => {
|
||||||
var dvbs = createDirectiveVariableBindings(
|
var dvbs = createDirectiveVariableBindings(
|
||||||
new renderApi.ElementBinder({
|
new RenderElementBinder({
|
||||||
variableBindings:
|
variableBindings:
|
||||||
MapWrapper.createFromStringMap<string>({"exportName": "templateName"})
|
MapWrapper.createFromStringMap<string>({"exportName": "templateName"})
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
directiveBinding(
|
directiveBinding(
|
||||||
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}),
|
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})}),
|
||||||
directiveBinding(
|
directiveBinding(
|
||||||
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'otherName'})})
|
{metadata: RenderDirectiveMetadata.create({exportAs: 'otherName'})})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(dvbs).toEqual(MapWrapper.createFromStringMap<number>({"templateName": 0}));
|
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", () => {
|
it("should set exportAs to $implicit for component with exportAs = null", () => {
|
||||||
var dvbs = createDirectiveVariableBindings(
|
var dvbs = createDirectiveVariableBindings(
|
||||||
new renderApi.ElementBinder({
|
new RenderElementBinder({
|
||||||
variableBindings:
|
variableBindings:
|
||||||
MapWrapper.createFromStringMap<string>({"$implicit": "templateName"})
|
MapWrapper.createFromStringMap<string>({"$implicit": "templateName"})
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
directiveBinding({
|
directiveBinding({
|
||||||
metadata: renderApi.DirectiveMetadata.create(
|
metadata: RenderDirectiveMetadata.create(
|
||||||
{exportAs: null, type: renderApi.DirectiveMetadata.COMPONENT_TYPE})
|
{exportAs: null, type: RenderDirectiveMetadata.COMPONENT_TYPE})
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -114,13 +121,13 @@ export function main() {
|
||||||
it("should throw we no directive exported with this name", () => {
|
it("should throw we no directive exported with this name", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
createDirectiveVariableBindings(
|
createDirectiveVariableBindings(
|
||||||
new renderApi.ElementBinder({
|
new RenderElementBinder({
|
||||||
variableBindings:
|
variableBindings:
|
||||||
MapWrapper.createFromStringMap<string>({"someInvalidName": "templateName"})
|
MapWrapper.createFromStringMap<string>({"someInvalidName": "templateName"})
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
directiveBinding(
|
directiveBinding(
|
||||||
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})})
|
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})})
|
||||||
]);
|
]);
|
||||||
}).toThrowError(new RegExp("Cannot find directive with exportAs = 'someInvalidName'"));
|
}).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", () => {
|
it("should throw when binding to a name exported by two directives", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
createDirectiveVariableBindings(
|
createDirectiveVariableBindings(
|
||||||
new renderApi.ElementBinder({
|
new RenderElementBinder({
|
||||||
variableBindings:
|
variableBindings:
|
||||||
MapWrapper.createFromStringMap<string>({"exportName": "templateName"})
|
MapWrapper.createFromStringMap<string>({"exportName": "templateName"})
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
directiveBinding(
|
directiveBinding(
|
||||||
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}),
|
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})}),
|
||||||
directiveBinding(
|
directiveBinding(
|
||||||
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})})
|
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})})
|
||||||
]);
|
]);
|
||||||
}).toThrowError(new RegExp("More than one directive have 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", () => {
|
it("should not throw when not binding to a name exported by two directives", () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
createDirectiveVariableBindings(
|
createDirectiveVariableBindings(new RenderElementBinder({variableBindings: new Map()}), [
|
||||||
new renderApi.ElementBinder({variableBindings: new Map()}), [
|
directiveBinding({metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})}),
|
||||||
directiveBinding(
|
directiveBinding(
|
||||||
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})}),
|
{metadata: RenderDirectiveMetadata.create({exportAs: 'exportName'})})
|
||||||
directiveBinding(
|
|
||||||
{metadata: renderApi.DirectiveMetadata.create({exportAs: 'exportName'})})
|
|
||||||
]);
|
]);
|
||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
@ -157,9 +162,9 @@ export function main() {
|
||||||
describe('createVariableLocations', () => {
|
describe('createVariableLocations', () => {
|
||||||
it('should merge the names in the template for all ElementBinders', () => {
|
it('should merge the names in the template for all ElementBinders', () => {
|
||||||
expect(createVariableLocations([
|
expect(createVariableLocations([
|
||||||
new renderApi.ElementBinder(
|
new RenderElementBinder(
|
||||||
{variableBindings: MapWrapper.createFromStringMap<string>({"x": "a"})}),
|
{variableBindings: MapWrapper.createFromStringMap<string>({"x": "a"})}),
|
||||||
new renderApi.ElementBinder(
|
new RenderElementBinder(
|
||||||
{variableBindings: MapWrapper.createFromStringMap<string>({"y": "b"})})
|
{variableBindings: MapWrapper.createFromStringMap<string>({"y": "b"})})
|
||||||
|
|
||||||
])).toEqual(MapWrapper.createFromStringMap<number>({'a': 0, 'b': 1}));
|
])).toEqual(MapWrapper.createFromStringMap<number>({'a': 0, 'b': 1}));
|
||||||
|
@ -175,10 +180,10 @@ export function main() {
|
||||||
it("should return template event records", () => {
|
it("should return template event records", () => {
|
||||||
var rec = creator.getEventBindingRecords(
|
var rec = creator.getEventBindingRecords(
|
||||||
[
|
[
|
||||||
new renderApi.ElementBinder(
|
new RenderElementBinder(
|
||||||
{eventBindings: [new renderApi.EventBinding("a", null)], directives: []}),
|
{eventBindings: [new EventBinding("a", null)], directives: []}),
|
||||||
new renderApi.ElementBinder(
|
new RenderElementBinder(
|
||||||
{eventBindings: [new renderApi.EventBinding("b", null)], directives: []})
|
{eventBindings: [new EventBinding("b", null)], directives: []})
|
||||||
],
|
],
|
||||||
[]);
|
[]);
|
||||||
|
|
||||||
|
@ -191,17 +196,15 @@ export function main() {
|
||||||
it('should return host event records', () => {
|
it('should return host event records', () => {
|
||||||
var rec = creator.getEventBindingRecords(
|
var rec = creator.getEventBindingRecords(
|
||||||
[
|
[
|
||||||
new renderApi.ElementBinder({
|
new RenderElementBinder({
|
||||||
eventBindings: [],
|
eventBindings: [],
|
||||||
directives: [
|
directives: [
|
||||||
new renderApi.DirectiveBinder({
|
new DirectiveBinder(
|
||||||
directiveIndex: 0,
|
{directiveIndex: 0, eventBindings: [new EventBinding("a", null)]})
|
||||||
eventBindings: [new renderApi.EventBinding("a", null)]
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
[renderApi.DirectiveMetadata.create({id: 'some-id'})]);
|
[RenderDirectiveMetadata.create({id: 'some-id'})]);
|
||||||
|
|
||||||
expect(rec.length).toEqual(1);
|
expect(rec.length).toEqual(1);
|
||||||
expect(rec[0].eventName).toEqual("a");
|
expect(rec[0].eventName).toEqual("a");
|
||||||
|
@ -216,10 +219,10 @@ function directiveBinding({metadata}: {metadata?: any} = {}) {
|
||||||
return new DirectiveBinding(Key.get("dummy"), null, [], [], [], metadata);
|
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) {
|
variableBindings = null) {
|
||||||
if (isBlank(type)) {
|
if (isBlank(type)) {
|
||||||
type = renderApi.ViewType.COMPONENT;
|
type = ViewType.COMPONENT;
|
||||||
}
|
}
|
||||||
if (isBlank(elementBinders)) {
|
if (isBlank(elementBinders)) {
|
||||||
elementBinders = [];
|
elementBinders = [];
|
||||||
|
@ -227,7 +230,7 @@ function createRenderProtoView(elementBinders = null, type: renderApi.ViewType =
|
||||||
if (isBlank(variableBindings)) {
|
if (isBlank(variableBindings)) {
|
||||||
variableBindings = new Map();
|
variableBindings = new Map();
|
||||||
}
|
}
|
||||||
return new renderApi.ProtoViewDto({
|
return new ProtoViewDto({
|
||||||
elementBinders: elementBinders,
|
elementBinders: elementBinders,
|
||||||
type: type,
|
type: type,
|
||||||
variableBindings: variableBindings,
|
variableBindings: variableBindings,
|
||||||
|
@ -237,12 +240,12 @@ function createRenderProtoView(elementBinders = null, type: renderApi.ViewType =
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRenderComponentElementBinder(directiveIndex) {
|
function createRenderComponentElementBinder(directiveIndex) {
|
||||||
return new renderApi.ElementBinder(
|
return new RenderElementBinder(
|
||||||
{directives: [new renderApi.DirectiveBinder({directiveIndex: directiveIndex})]});
|
{directives: [new DirectiveBinder({directiveIndex: directiveIndex})]});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRenderViewportElementBinder(nestedProtoView) {
|
function createRenderViewportElementBinder(nestedProtoView) {
|
||||||
return new renderApi.ElementBinder({nestedProtoView: nestedProtoView});
|
return new RenderElementBinder({nestedProtoView: nestedProtoView});
|
||||||
}
|
}
|
||||||
|
|
||||||
@proxy
|
@proxy
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {
|
||||||
|
|
||||||
import {Injectable, Optional} from 'angular2/di';
|
import {Injectable, Optional} from 'angular2/di';
|
||||||
import {QueryList, TemplateRef} from 'angular2/core';
|
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';
|
import {NgIf, NgFor} from 'angular2/angular2';
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import {
|
||||||
ProtoElementInjector
|
ProtoElementInjector
|
||||||
} from 'angular2/src/core/compiler/element_injector';
|
} from 'angular2/src/core/compiler/element_injector';
|
||||||
import {DirectiveResolver} from 'angular2/src/core/compiler/directive_resolver';
|
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 {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils';
|
||||||
import {
|
import {
|
||||||
RenderProtoViewMergeMapping,
|
RenderProtoViewMergeMapping,
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {Directive, Component, View, LifecycleEvent} from 'angular2/angular2';
|
import {Directive, Component, View, LifecycleEvent} from 'angular2/angular2';
|
||||||
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
|
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('directive lifecycle integration spec', () => {
|
describe('directive lifecycle integration spec', () => {
|
||||||
|
@ -22,7 +21,7 @@ export function main() {
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
tcb.overrideView(
|
tcb.overrideView(
|
||||||
MyComp,
|
MyComp,
|
||||||
new viewAnn.View(
|
new View(
|
||||||
{template: '<div [field]="123" lifecycle></div>', directives: [LifecycleDir]}))
|
{template: '<div [field]="123" lifecycle></div>', directives: [LifecycleDir]}))
|
||||||
.createAsync(MyComp)
|
.createAsync(MyComp)
|
||||||
.then((tc) => {
|
.then((tc) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {
|
||||||
it,
|
it,
|
||||||
xit
|
xit
|
||||||
} from 'angular2/test_lib';
|
} 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 {QueryList, NgFor} from 'angular2/angular2';
|
||||||
import {forwardRef, resolveForwardRef, bind, Inject} from 'angular2/di';
|
import {forwardRef, resolveForwardRef, bind, Inject} from 'angular2/di';
|
||||||
import {Type} from 'angular2/src/facade/lang';
|
import {Type} from 'angular2/src/facade/lang';
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {
|
||||||
} from 'angular2/test_lib';
|
} from 'angular2/test_lib';
|
||||||
|
|
||||||
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
|
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 {}
|
class MyPipe {}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {PipeTransform} from 'angular2/change_detection';
|
||||||
import {Injector, Inject, bind} from 'angular2/di';
|
import {Injector, Inject, bind} from 'angular2/di';
|
||||||
import {ProtoPipes, Pipes} from 'angular2/src/core/pipes/pipes';
|
import {ProtoPipes, Pipes} from 'angular2/src/core/pipes/pipes';
|
||||||
import {PipeBinding} from 'angular2/src/core/pipes/pipe_binding';
|
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 {
|
class PipeA implements PipeTransform {
|
||||||
transform(a, b) {}
|
transform(a, b) {}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {
|
||||||
Directive,
|
Directive,
|
||||||
Component,
|
Component,
|
||||||
View,
|
View,
|
||||||
} from 'angular2/annotations';
|
} from 'angular2/metadata';
|
||||||
|
|
||||||
import {NgFor} from 'angular2/src/directives/ng_for';
|
import {NgFor} from 'angular2/src/directives/ng_for';
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import {
|
||||||
Directive,
|
Directive,
|
||||||
Component,
|
Component,
|
||||||
View,
|
View,
|
||||||
} from 'angular2/annotations';
|
} from 'angular2/metadata';
|
||||||
import {IS_DART} from '../platform';
|
import {IS_DART} from '../platform';
|
||||||
|
|
||||||
@Component({selector: 'my-comp'})
|
@Component({selector: 'my-comp'})
|
||||||
|
|
|
@ -16,8 +16,6 @@ import {Component, View} from 'angular2/angular2';
|
||||||
|
|
||||||
import {isBlank} from 'angular2/src/facade/lang';
|
import {isBlank} from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
import * as viewImpl from 'angular2/src/core/annotations_impl/view';
|
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('MockViewResolver', () => {
|
describe('MockViewResolver', () => {
|
||||||
var viewResolver;
|
var viewResolver;
|
||||||
|
@ -32,7 +30,7 @@ export function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow overriding the @View', () => {
|
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);
|
var view = viewResolver.resolve(SomeComponent);
|
||||||
expect(view.template).toEqual('overridden template');
|
expect(view.template).toEqual('overridden template');
|
||||||
expect(isBlank(view.directives)).toBe(true);
|
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', () => {
|
it('should not allow overriding a view after it has been resolved', () => {
|
||||||
viewResolver.resolve(SomeComponent);
|
viewResolver.resolve(SomeComponent);
|
||||||
expect(() => {
|
expect(() => {
|
||||||
viewResolver.setView(SomeComponent, new viewImpl.View({template: 'overridden template'}));
|
viewResolver.setView(SomeComponent, new View({template: 'overridden template'}));
|
||||||
})
|
})
|
||||||
.toThrowError(
|
.toThrowError(
|
||||||
`The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
|
`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', () => {
|
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');
|
viewResolver.setInlineTemplate(SomeComponent, 'overridden template x 2');
|
||||||
var view = viewResolver.resolve(SomeComponent);
|
var view = viewResolver.resolve(SomeComponent);
|
||||||
expect(view.template).toEqual('overridden template x 2');
|
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', () => {
|
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);
|
viewResolver.overrideViewDirective(SomeComponent, SomeOtherDirective, SomeComponent);
|
||||||
var view = viewResolver.resolve(SomeComponent);
|
var view = viewResolver.resolve(SomeComponent);
|
||||||
expect(view.directives.length).toEqual(1);
|
expect(view.directives.length).toEqual(1);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue