refactor(core): remove `…Metadata` for all decorators and use the decorator directly.
BREAKING CHANGE: - all `…Metadata` classes have been removed. Use the corresponding decorator as constructor or for `instanceof` checks instead. - Example: * Before: `new ComponentMetadata(…)` * After: `new Component(…)` - Note: `new Component(…)` worked before as well.
This commit is contained in:
parent
1b15170c89
commit
63e15ffaec
|
@ -11,7 +11,7 @@
|
|||
* Intended to be used in a build step.
|
||||
*/
|
||||
import * as compiler from '@angular/compiler';
|
||||
import {ComponentMetadata, NgModuleMetadata, ViewEncapsulation} from '@angular/core';
|
||||
import {Component, NgModule, ViewEncapsulation} from '@angular/core';
|
||||
import {AngularCompilerOptions, NgcCliOptions} from '@angular/tsc-wrapped';
|
||||
import * as path from 'path';
|
||||
import * as ts from 'typescript';
|
||||
|
@ -62,9 +62,9 @@ export class CodeGenerator {
|
|||
const staticType = this.reflectorHost.findDeclaration(absSourcePath, symbol, absSourcePath);
|
||||
const annotations = this.staticReflector.annotations(staticType);
|
||||
annotations.forEach((annotation) => {
|
||||
if (annotation instanceof NgModuleMetadata) {
|
||||
if (annotation instanceof NgModule) {
|
||||
result.ngModules.push(staticType);
|
||||
} else if (annotation instanceof ComponentMetadata) {
|
||||
} else if (annotation instanceof Component) {
|
||||
result.components.push(staticType);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import 'reflect-metadata';
|
||||
|
||||
import * as compiler from '@angular/compiler';
|
||||
import {ComponentMetadata, NgModuleMetadata, ViewEncapsulation} from '@angular/core';
|
||||
import {Component, NgModule, ViewEncapsulation} from '@angular/core';
|
||||
import * as path from 'path';
|
||||
import * as ts from 'typescript';
|
||||
import * as tsc from '@angular/tsc-wrapped';
|
||||
|
@ -87,9 +87,9 @@ export class Extractor {
|
|||
const staticType = this.reflectorHost.findDeclaration(absSourcePath, symbol, absSourcePath);
|
||||
const annotations = this.staticReflector.annotations(staticType);
|
||||
annotations.forEach((annotation) => {
|
||||
if (annotation instanceof NgModuleMetadata) {
|
||||
if (annotation instanceof NgModule) {
|
||||
result.ngModules.push(staticType);
|
||||
} else if (annotation instanceof ComponentMetadata) {
|
||||
} else if (annotation instanceof Component) {
|
||||
result.components.push(staticType);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AttributeMetadata, ComponentMetadata, ContentChildMetadata, ContentChildrenMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, HostMetadata, InjectMetadata, InjectableMetadata, InputMetadata, NgModuleMetadata, OptionalMetadata, OutputMetadata, PipeMetadata, QueryMetadata, SelfMetadata, SkipSelfMetadata, ViewChildMetadata, ViewChildrenMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
|
||||
import {Attribute, Component, ContentChild, ContentChildren, Directive, Host, HostBinding, HostListener, Inject, Injectable, Input, NgModule, Optional, Output, Pipe, Query, Self, SkipSelf, ViewChild, ViewChildren, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
|
||||
|
||||
import {ReflectorReader} from './private_import_core';
|
||||
|
||||
|
@ -181,54 +181,47 @@ export class StaticReflector implements ReflectorReader {
|
|||
this.host.angularImportLocations();
|
||||
this.opaqueToken = this.host.findDeclaration(diOpaqueToken, 'OpaqueToken');
|
||||
|
||||
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'Host'), Host);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diDecorators, 'Host'), HostMetadata);
|
||||
this.host.findDeclaration(diDecorators, 'Injectable'), Injectable);
|
||||
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'Self'), Self);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diDecorators, 'Injectable'), InjectableMetadata);
|
||||
this.host.findDeclaration(diDecorators, 'SkipSelf'), SkipSelf);
|
||||
this.registerDecoratorOrConstructor(this.host.findDeclaration(diDecorators, 'Inject'), Inject);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diDecorators, 'Self'), SelfMetadata);
|
||||
this.host.findDeclaration(diDecorators, 'Optional'), Optional);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diDecorators, 'SkipSelf'), SkipSelfMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'Attribute'), Attribute);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diDecorators, 'Inject'), InjectMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'ContentChild'), ContentChild);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diDecorators, 'Optional'), OptionalMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'ContentChildren'), ContentChildren);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'Attribute'), AttributeMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'ViewChild'), ViewChild);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'ContentChild'), ContentChildMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'ViewChildren'), ViewChildren);
|
||||
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Input'), Input);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'ContentChildren'), ContentChildrenMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'Output'), Output);
|
||||
this.registerDecoratorOrConstructor(this.host.findDeclaration(coreDecorators, 'Pipe'), Pipe);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'ViewChild'), ViewChildMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'HostBinding'), HostBinding);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'ViewChildren'), ViewChildrenMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'HostListener'), HostListener);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'Input'), InputMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'Directive'), Directive);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'Output'), OutputMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'Component'), Component);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'Pipe'), PipeMetadata);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'HostBinding'), HostBindingMetadata);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'HostListener'), HostListenerMetadata);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'Directive'), DirectiveMetadata);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'Component'), ComponentMetadata);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(coreDecorators, 'NgModule'), NgModuleMetadata);
|
||||
this.host.findDeclaration(coreDecorators, 'NgModule'), NgModule);
|
||||
|
||||
// Note: Some metadata classes can be used directly with Provider.deps.
|
||||
this.registerDecoratorOrConstructor(this.host.findDeclaration(diMetadata, 'Host'), Host);
|
||||
this.registerDecoratorOrConstructor(this.host.findDeclaration(diMetadata, 'Self'), Self);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diMetadata, 'HostMetadata'), HostMetadata);
|
||||
this.host.findDeclaration(diMetadata, 'SkipSelf'), SkipSelf);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diMetadata, 'SelfMetadata'), SelfMetadata);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diMetadata, 'SkipSelfMetadata'), SkipSelfMetadata);
|
||||
this.registerDecoratorOrConstructor(
|
||||
this.host.findDeclaration(diMetadata, 'OptionalMetadata'), OptionalMetadata);
|
||||
this.host.findDeclaration(diMetadata, 'Optional'), Optional);
|
||||
|
||||
this.registerFunction(this.host.findDeclaration(animationMetadata, 'trigger'), trigger);
|
||||
this.registerFunction(this.host.findDeclaration(animationMetadata, 'state'), state);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler-cli/src/static_reflector';
|
||||
import {HostListenerMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
|
||||
import {HostListener, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
|
||||
import {ListWrapper} from '@angular/facade/src/collection';
|
||||
import {isBlank} from '@angular/facade/src/lang';
|
||||
import {MetadataCollector} from '@angular/tsc-wrapped';
|
||||
|
@ -92,7 +92,7 @@ describe('StaticReflector', () => {
|
|||
host.findDeclaration('src/app/hero-detail.component', 'HeroDetailComponent');
|
||||
let props = reflector.propMetadata(HeroDetailComponent);
|
||||
expect(props['hero']).toBeTruthy();
|
||||
expect(props['onMouseOver']).toEqual([new HostListenerMetadata('mouseover', ['$event'])]);
|
||||
expect(props['onMouseOver']).toEqual([new HostListener('mouseover', ['$event'])]);
|
||||
});
|
||||
|
||||
it('should get an empty object from propMetadata for an unknown class', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {COMPILER_OPTIONS, ClassProvider, Compiler, CompilerFactory, CompilerOptions, Component, ExistingProvider, FactoryProvider, Inject, Injectable, OptionalMetadata, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, TypeProvider, ValueProvider, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core';
|
||||
import {COMPILER_OPTIONS, ClassProvider, Compiler, CompilerFactory, CompilerOptions, Component, ExistingProvider, FactoryProvider, Inject, Injectable, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, TypeProvider, ValueProvider, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core';
|
||||
|
||||
export * from './template_parser/template_ast';
|
||||
export {TEMPLATE_TRANSFORMS} from './template_parser/template_parser';
|
||||
|
@ -66,8 +66,8 @@ export const COMPILER_PROVIDERS: Array<any|Type<any>|{[k: string]: any}|any[]> =
|
|||
new i18n.I18NHtmlParser(parser, translations, format),
|
||||
deps: [
|
||||
HtmlParser,
|
||||
[new OptionalMetadata(), new Inject(TRANSLATIONS)],
|
||||
[new OptionalMetadata(), new Inject(TRANSLATIONS_FORMAT)],
|
||||
[new Optional(), new Inject(TRANSLATIONS)],
|
||||
[new Optional(), new Inject(TRANSLATIONS_FORMAT)],
|
||||
]
|
||||
},
|
||||
TemplateParser,
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, Injectable, InputMetadata, OutputMetadata, QueryMetadata, Type, resolveForwardRef} from '@angular/core';
|
||||
import {Component, Directive, HostBinding, HostListener, Injectable, Input, Output, Query, Type, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {StringMapWrapper} from './facade/collection';
|
||||
import {isPresent, stringify} from './facade/lang';
|
||||
import {ReflectorReader, reflector} from './private_import_core';
|
||||
import {splitAtColon} from './util';
|
||||
|
||||
function _isDirectiveMetadata(type: any): type is DirectiveMetadata {
|
||||
return type instanceof DirectiveMetadata;
|
||||
function _isDirectiveMetadata(type: any): type is Directive {
|
||||
return type instanceof Directive;
|
||||
}
|
||||
|
||||
/*
|
||||
* Resolve a `Type` for {@link DirectiveMetadata}.
|
||||
* Resolve a `Type` for {@link Directive}.
|
||||
*
|
||||
* This interface can be overridden by the application developer to create custom behavior.
|
||||
*
|
||||
|
@ -29,9 +29,9 @@ export class DirectiveResolver {
|
|||
constructor(private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
/**
|
||||
* Return {@link DirectiveMetadata} for a given `Type`.
|
||||
* Return {@link Directive} for a given `Type`.
|
||||
*/
|
||||
resolve(type: Type<any>, throwIfNotFound = true): DirectiveMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): Directive {
|
||||
var typeMetadata = this._reflector.annotations(resolveForwardRef(type));
|
||||
if (isPresent(typeMetadata)) {
|
||||
var metadata = typeMetadata.find(_isDirectiveMetadata);
|
||||
|
@ -47,8 +47,8 @@ export class DirectiveResolver {
|
|||
}
|
||||
|
||||
private _mergeWithPropertyMetadata(
|
||||
dm: DirectiveMetadata, propertyMetadata: {[key: string]: any[]},
|
||||
directiveType: Type<any>): DirectiveMetadata {
|
||||
dm: Directive, propertyMetadata: {[key: string]: any[]},
|
||||
directiveType: Type<any>): Directive {
|
||||
var inputs: string[] = [];
|
||||
var outputs: string[] = [];
|
||||
var host: {[key: string]: string} = {};
|
||||
|
@ -56,31 +56,31 @@ export class DirectiveResolver {
|
|||
|
||||
StringMapWrapper.forEach(propertyMetadata, (metadata: any[], propName: string) => {
|
||||
metadata.forEach(a => {
|
||||
if (a instanceof InputMetadata) {
|
||||
if (a instanceof Input) {
|
||||
if (isPresent(a.bindingPropertyName)) {
|
||||
inputs.push(`${propName}: ${a.bindingPropertyName}`);
|
||||
} else {
|
||||
inputs.push(propName);
|
||||
}
|
||||
} else if (a instanceof OutputMetadata) {
|
||||
const output: OutputMetadata = a;
|
||||
} else if (a instanceof Output) {
|
||||
const output: Output = a;
|
||||
if (isPresent(output.bindingPropertyName)) {
|
||||
outputs.push(`${propName}: ${output.bindingPropertyName}`);
|
||||
} else {
|
||||
outputs.push(propName);
|
||||
}
|
||||
} else if (a instanceof HostBindingMetadata) {
|
||||
const hostBinding: HostBindingMetadata = a;
|
||||
} else if (a instanceof HostBinding) {
|
||||
const hostBinding: HostBinding = a;
|
||||
if (isPresent(hostBinding.hostPropertyName)) {
|
||||
host[`[${hostBinding.hostPropertyName}]`] = propName;
|
||||
} else {
|
||||
host[`[${propName}]`] = propName;
|
||||
}
|
||||
} else if (a instanceof HostListenerMetadata) {
|
||||
const hostListener: HostListenerMetadata = a;
|
||||
} else if (a instanceof HostListener) {
|
||||
const hostListener: HostListener = a;
|
||||
var args = isPresent(hostListener.args) ? (<any[]>hostListener.args).join(', ') : '';
|
||||
host[`(${hostListener.eventName})`] = `${propName}(${args})`;
|
||||
} else if (a instanceof QueryMetadata) {
|
||||
} else if (a instanceof Query) {
|
||||
queries[propName] = a;
|
||||
}
|
||||
});
|
||||
|
@ -91,8 +91,8 @@ export class DirectiveResolver {
|
|||
private _extractPublicName(def: string) { return splitAtColon(def, [null, def])[1].trim(); }
|
||||
|
||||
private _merge(
|
||||
dm: DirectiveMetadata, inputs: string[], outputs: string[], host: {[key: string]: string},
|
||||
queries: {[key: string]: any}, directiveType: Type<any>): DirectiveMetadata {
|
||||
dm: Directive, inputs: string[], outputs: string[], host: {[key: string]: string},
|
||||
queries: {[key: string]: any}, directiveType: Type<any>): Directive {
|
||||
let mergedInputs: string[];
|
||||
|
||||
if (isPresent(dm.inputs)) {
|
||||
|
@ -132,8 +132,8 @@ export class DirectiveResolver {
|
|||
var mergedQueries =
|
||||
isPresent(dm.queries) ? StringMapWrapper.merge(dm.queries, queries) : queries;
|
||||
|
||||
if (dm instanceof ComponentMetadata) {
|
||||
return new ComponentMetadata({
|
||||
if (dm instanceof Component) {
|
||||
return new Component({
|
||||
selector: dm.selector,
|
||||
inputs: mergedInputs,
|
||||
outputs: mergedOutputs,
|
||||
|
@ -155,7 +155,7 @@ export class DirectiveResolver {
|
|||
});
|
||||
|
||||
} else {
|
||||
return new DirectiveMetadata({
|
||||
return new Directive({
|
||||
selector: dm.selector,
|
||||
inputs: mergedInputs,
|
||||
outputs: mergedOutputs,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, AttributeMetadata, ChangeDetectionStrategy, ComponentMetadata, HostMetadata, InjectMetadata, Injectable, ModuleWithProviders, OptionalMetadata, Provider, QueryMetadata, SchemaMetadata, SelfMetadata, SkipSelfMetadata, Type, resolveForwardRef} from '@angular/core';
|
||||
import {AnimationAnimateMetadata, AnimationEntryMetadata, AnimationGroupMetadata, AnimationKeyframesSequenceMetadata, AnimationMetadata, AnimationStateDeclarationMetadata, AnimationStateMetadata, AnimationStateTransitionMetadata, AnimationStyleMetadata, AnimationWithStepsMetadata, Attribute, ChangeDetectionStrategy, Component, Host, Inject, Injectable, ModuleWithProviders, Optional, Provider, Query, SchemaMetadata, Self, SkipSelf, Type, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {StringMapWrapper} from '../src/facade/collection';
|
||||
|
||||
|
@ -55,7 +55,7 @@ export class CompileMetadataResolver {
|
|||
this._directiveCache.delete(type);
|
||||
this._pipeCache.delete(type);
|
||||
this._ngModuleOfTypes.delete(type);
|
||||
// Clear all of the NgModuleMetadata as they contain transitive information!
|
||||
// Clear all of the NgModule as they contain transitive information!
|
||||
this._ngModuleCache.clear();
|
||||
}
|
||||
|
||||
|
@ -123,8 +123,8 @@ export class CompileMetadataResolver {
|
|||
var moduleUrl = staticTypeModuleUrl(directiveType);
|
||||
var entryComponentMetadata: cpl.CompileTypeMetadata[] = [];
|
||||
let selector = dirMeta.selector;
|
||||
if (dirMeta instanceof ComponentMetadata) {
|
||||
var cmpMeta = <ComponentMetadata>dirMeta;
|
||||
if (dirMeta instanceof Component) {
|
||||
var cmpMeta = <Component>dirMeta;
|
||||
assertArrayOfStrings('styles', cmpMeta.styles);
|
||||
assertInterpolationSymbols('interpolation', cmpMeta.interpolation);
|
||||
var animations = isPresent(cmpMeta.animations) ?
|
||||
|
@ -483,29 +483,29 @@ export class CompileMetadataResolver {
|
|||
let isSelf = false;
|
||||
let isSkipSelf = false;
|
||||
let isOptional = false;
|
||||
let query: QueryMetadata = null;
|
||||
let viewQuery: QueryMetadata = null;
|
||||
let query: Query = null;
|
||||
let viewQuery: Query = null;
|
||||
var token: any = null;
|
||||
if (isArray(param)) {
|
||||
(<any[]>param).forEach((paramEntry) => {
|
||||
if (paramEntry instanceof HostMetadata) {
|
||||
if (paramEntry instanceof Host) {
|
||||
isHost = true;
|
||||
} else if (paramEntry instanceof SelfMetadata) {
|
||||
} else if (paramEntry instanceof Self) {
|
||||
isSelf = true;
|
||||
} else if (paramEntry instanceof SkipSelfMetadata) {
|
||||
} else if (paramEntry instanceof SkipSelf) {
|
||||
isSkipSelf = true;
|
||||
} else if (paramEntry instanceof OptionalMetadata) {
|
||||
} else if (paramEntry instanceof Optional) {
|
||||
isOptional = true;
|
||||
} else if (paramEntry instanceof AttributeMetadata) {
|
||||
} else if (paramEntry instanceof Attribute) {
|
||||
isAttribute = true;
|
||||
token = paramEntry.attributeName;
|
||||
} else if (paramEntry instanceof QueryMetadata) {
|
||||
} else if (paramEntry instanceof Query) {
|
||||
if (paramEntry.isViewQuery) {
|
||||
viewQuery = paramEntry;
|
||||
} else {
|
||||
query = paramEntry;
|
||||
}
|
||||
} else if (paramEntry instanceof InjectMetadata) {
|
||||
} else if (paramEntry instanceof Inject) {
|
||||
token = paramEntry.token;
|
||||
} else if (isValidType(paramEntry) && isBlank(token)) {
|
||||
token = paramEntry;
|
||||
|
@ -653,10 +653,10 @@ export class CompileMetadataResolver {
|
|||
}
|
||||
|
||||
getQueriesMetadata(
|
||||
queries: {[key: string]: QueryMetadata}, isViewQuery: boolean,
|
||||
queries: {[key: string]: Query}, isViewQuery: boolean,
|
||||
directiveType: Type<any>): cpl.CompileQueryMetadata[] {
|
||||
var res: cpl.CompileQueryMetadata[] = [];
|
||||
StringMapWrapper.forEach(queries, (query: QueryMetadata, propertyName: string) => {
|
||||
StringMapWrapper.forEach(queries, (query: Query, propertyName: string) => {
|
||||
if (query.isViewQuery === isViewQuery) {
|
||||
res.push(this.getQueryMetadata(query, propertyName, directiveType));
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ export class CompileMetadataResolver {
|
|||
}
|
||||
|
||||
|
||||
getQueryMetadata(q: QueryMetadata, propertyName: string, typeOrFunc: Type<any>|Function):
|
||||
getQueryMetadata(q: Query, propertyName: string, typeOrFunc: Type<any>|Function):
|
||||
cpl.CompileQueryMetadata {
|
||||
var selectors: cpl.CompileTokenMetadata[];
|
||||
if (isString(q.selector)) {
|
||||
|
@ -733,8 +733,7 @@ function staticTypeModuleUrl(value: any): string {
|
|||
return cpl.isStaticSymbol(value) ? value.filePath : null;
|
||||
}
|
||||
|
||||
function componentModuleUrl(
|
||||
reflector: ReflectorReader, type: any, cmpMetadata: ComponentMetadata): string {
|
||||
function componentModuleUrl(reflector: ReflectorReader, type: any, cmpMetadata: Component): string {
|
||||
if (cpl.isStaticSymbol(type)) {
|
||||
return staticTypeModuleUrl(type);
|
||||
}
|
||||
|
|
|
@ -6,25 +6,24 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injectable, NgModuleMetadata, Type} from '@angular/core';
|
||||
import {Injectable, NgModule, Type} from '@angular/core';
|
||||
|
||||
import {isPresent, stringify} from './facade/lang';
|
||||
import {ReflectorReader, reflector} from './private_import_core';
|
||||
|
||||
function _isNgModuleMetadata(obj: any): obj is NgModuleMetadata {
|
||||
return obj instanceof NgModuleMetadata;
|
||||
function _isNgModuleMetadata(obj: any): obj is NgModule {
|
||||
return obj instanceof NgModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves types to {@link NgModuleMetadata}.
|
||||
* Resolves types to {@link NgModule}.
|
||||
*/
|
||||
@Injectable()
|
||||
export class NgModuleResolver {
|
||||
constructor(private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
resolve(type: Type<any>, throwIfNotFound = true): NgModuleMetadata {
|
||||
const ngModuleMeta: NgModuleMetadata =
|
||||
this._reflector.annotations(type).find(_isNgModuleMetadata);
|
||||
resolve(type: Type<any>, throwIfNotFound = true): NgModule {
|
||||
const ngModuleMeta: NgModule = this._reflector.annotations(type).find(_isNgModuleMetadata);
|
||||
|
||||
if (isPresent(ngModuleMeta)) {
|
||||
return ngModuleMeta;
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injectable, PipeMetadata, Type, resolveForwardRef} from '@angular/core';
|
||||
import {Injectable, Pipe, Type, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {isPresent, stringify} from './facade/lang';
|
||||
import {ReflectorReader, reflector} from './private_import_core';
|
||||
|
||||
function _isPipeMetadata(type: any): boolean {
|
||||
return type instanceof PipeMetadata;
|
||||
return type instanceof Pipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a `Type` for {@link PipeMetadata}.
|
||||
* Resolve a `Type` for {@link Pipe}.
|
||||
*
|
||||
* This interface can be overridden by the application developer to create custom behavior.
|
||||
*
|
||||
|
@ -27,9 +27,9 @@ export class PipeResolver {
|
|||
constructor(private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
/**
|
||||
* Return {@link PipeMetadata} for a given `Type`.
|
||||
* Return {@link Pipe} for a given `Type`.
|
||||
*/
|
||||
resolve(type: Type<any>, throwIfNotFound = true): PipeMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): Pipe {
|
||||
var metas = this._reflector.annotations(resolveForwardRef(type));
|
||||
if (isPresent(metas)) {
|
||||
var annotation = metas.find(_isPipeMetadata);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Compiler, ComponentFactory, Injectable, Injector, ModuleWithComponentFactories, NgModuleFactory, OptionalMetadata, Provider, SchemaMetadata, SkipSelfMetadata, Type} from '@angular/core';
|
||||
import {Compiler, ComponentFactory, Injectable, Injector, ModuleWithComponentFactories, NgModuleFactory, Optional, Provider, SchemaMetadata, SkipSelf, Type} from '@angular/core';
|
||||
|
||||
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, CompilePipeMetadata, ProviderMeta, createHostComponentMeta} from './compile_metadata';
|
||||
import {CompilerConfig} from './config';
|
||||
|
|
|
@ -11,7 +11,7 @@ import {LifecycleHooks} from '@angular/core/src/metadata/lifecycle_hooks';
|
|||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe} from '@angular/core/testing/testing_internal';
|
||||
|
||||
export function main() {
|
||||
describe('Create DirectiveMetadata', () => {
|
||||
describe('Create Directive', () => {
|
||||
describe('lifecycle', () => {
|
||||
|
||||
describe('ngOnChanges', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, ComponentMetadata, Directive, Injector} from '@angular/core';
|
||||
import {Component, Directive, Injector} from '@angular/core';
|
||||
import {TestBed, inject} from '@angular/core/testing';
|
||||
|
||||
import {MockDirectiveResolver} from '../testing/index';
|
||||
|
@ -34,8 +34,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should allow overriding the @Directive', () => {
|
||||
dirResolver.setDirective(
|
||||
SomeComponent, new ComponentMetadata({selector: 'someOtherSelector'}));
|
||||
dirResolver.setDirective(SomeComponent, new Component({selector: 'someOtherSelector'}));
|
||||
var metadata = dirResolver.resolve(SomeComponent);
|
||||
expect(metadata.selector).toEqual('someOtherSelector');
|
||||
});
|
||||
|
@ -43,20 +42,20 @@ export function main() {
|
|||
|
||||
describe('View overriding', () => {
|
||||
it('should fallback to the default ViewResolver when templates are not overridden', () => {
|
||||
var view = <ComponentMetadata>dirResolver.resolve(SomeComponent);
|
||||
var view = <Component>dirResolver.resolve(SomeComponent);
|
||||
expect(view.template).toEqual('template');
|
||||
});
|
||||
|
||||
it('should allow overriding the @View', () => {
|
||||
dirResolver.setView(SomeComponent, new ViewMetadata({template: 'overridden template'}));
|
||||
var view = <ComponentMetadata>dirResolver.resolve(SomeComponent);
|
||||
var view = <Component>dirResolver.resolve(SomeComponent);
|
||||
expect(view.template).toEqual('overridden template');
|
||||
});
|
||||
|
||||
it('should allow overriding a view after it has been resolved', () => {
|
||||
dirResolver.resolve(SomeComponent);
|
||||
dirResolver.setView(SomeComponent, new ViewMetadata({template: 'overridden template'}));
|
||||
var view = <ComponentMetadata>dirResolver.resolve(SomeComponent);
|
||||
var view = <Component>dirResolver.resolve(SomeComponent);
|
||||
expect(view.template).toEqual('overridden template');
|
||||
});
|
||||
});
|
||||
|
@ -64,21 +63,21 @@ export function main() {
|
|||
describe('inline template definition overriding', () => {
|
||||
it('should allow overriding the default template', () => {
|
||||
dirResolver.setInlineTemplate(SomeComponent, 'overridden template');
|
||||
var view = <ComponentMetadata>dirResolver.resolve(SomeComponent);
|
||||
var view = <Component>dirResolver.resolve(SomeComponent);
|
||||
expect(view.template).toEqual('overridden template');
|
||||
});
|
||||
|
||||
it('should allow overriding an overridden @View', () => {
|
||||
dirResolver.setView(SomeComponent, new ViewMetadata({template: 'overridden template'}));
|
||||
dirResolver.setInlineTemplate(SomeComponent, 'overridden template x 2');
|
||||
var view = <ComponentMetadata>dirResolver.resolve(SomeComponent);
|
||||
var view = <Component>dirResolver.resolve(SomeComponent);
|
||||
expect(view.template).toEqual('overridden template x 2');
|
||||
});
|
||||
|
||||
it('should allow overriding a view after it has been resolved', () => {
|
||||
dirResolver.resolve(SomeComponent);
|
||||
dirResolver.setInlineTemplate(SomeComponent, 'overridden template');
|
||||
var view = <ComponentMetadata>dirResolver.resolve(SomeComponent);
|
||||
var view = <Component>dirResolver.resolve(SomeComponent);
|
||||
expect(view.template).toEqual('overridden template');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {DirectiveResolver} from '@angular/compiler/src/directive_resolver';
|
||||
import {Component, ComponentMetadata, ContentChild, ContentChildren, Directive, DirectiveMetadata, HostBinding, HostListener, Input, Output, ViewChild, ViewChildren} from '@angular/core/src/metadata';
|
||||
import {Component, ContentChild, ContentChildren, Directive, HostBinding, HostListener, Input, Output, ViewChild, ViewChildren} from '@angular/core/src/metadata';
|
||||
|
||||
@Directive({selector: 'someDirective'})
|
||||
class SomeDirective {
|
||||
|
@ -119,7 +119,7 @@ export function main() {
|
|||
it('should read out the Directive metadata', () => {
|
||||
var directiveMetadata = resolver.resolve(SomeDirective);
|
||||
expect(directiveMetadata)
|
||||
.toEqual(new DirectiveMetadata(
|
||||
.toEqual(new Directive(
|
||||
{selector: 'someDirective', inputs: [], outputs: [], host: {}, queries: {}}));
|
||||
});
|
||||
|
||||
|
@ -132,7 +132,7 @@ export function main() {
|
|||
it('should not read parent class Directive metadata', function() {
|
||||
var directiveMetadata = resolver.resolve(SomeChildDirective);
|
||||
expect(directiveMetadata)
|
||||
.toEqual(new DirectiveMetadata(
|
||||
.toEqual(new Directive(
|
||||
{selector: 'someChildDirective', inputs: [], outputs: [], host: {}, queries: {}}));
|
||||
});
|
||||
|
||||
|
@ -225,7 +225,7 @@ export function main() {
|
|||
|
||||
describe('view', () => {
|
||||
it('should read out the template related metadata from the Component metadata', () => {
|
||||
var compMetadata = <ComponentMetadata>resolver.resolve(ComponentWithTemplate);
|
||||
var compMetadata = <Component>resolver.resolve(ComponentWithTemplate);
|
||||
expect(compMetadata.template).toEqual('some template');
|
||||
expect(compMetadata.styles).toEqual(['some styles']);
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injector, NgModule, NgModuleMetadata} from '@angular/core';
|
||||
import {Injector, NgModule} from '@angular/core';
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {isBlank, stringify} from '../src/facade/lang';
|
||||
|
@ -29,7 +29,7 @@ export function main() {
|
|||
|
||||
it('should allow overriding the @NgModule', () => {
|
||||
ngModuleResolver.setNgModule(
|
||||
SomeNgModule, new NgModuleMetadata({declarations: [SomeOtherDirective]}));
|
||||
SomeNgModule, new NgModule({declarations: [SomeOtherDirective]}));
|
||||
var ngModule = ngModuleResolver.resolve(SomeNgModule);
|
||||
expect(ngModule.declarations).toEqual([SomeOtherDirective]);
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {NgModuleResolver} from '@angular/compiler/src/ng_module_resolver';
|
||||
import {NgModule, NgModuleMetadata} from '@angular/core/src/metadata';
|
||||
import {NgModule} from '@angular/core/src/metadata';
|
||||
import {stringify} from '../src/facade/lang';
|
||||
|
||||
class SomeClass1 {}
|
||||
|
@ -36,7 +36,7 @@ export function main() {
|
|||
|
||||
it('should read out the metadata from the class', () => {
|
||||
var moduleMetadata = resolver.resolve(SomeModule);
|
||||
expect(moduleMetadata).toEqual(new NgModuleMetadata({
|
||||
expect(moduleMetadata).toEqual(new NgModule({
|
||||
declarations: [SomeClass1],
|
||||
imports: [SomeClass2],
|
||||
exports: [SomeClass3],
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Injector, Pipe, PipeMetadata} from '@angular/core';
|
||||
import {Injector, Pipe} from '@angular/core';
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {isBlank, stringify} from '../src/facade/lang';
|
||||
|
@ -26,7 +26,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should allow overriding the @Pipe', () => {
|
||||
pipeResolver.setPipe(SomePipe, new PipeMetadata({name: 'someOtherName'}));
|
||||
pipeResolver.setPipe(SomePipe, new Pipe({name: 'someOtherName'}));
|
||||
var pipe = pipeResolver.resolve(SomePipe);
|
||||
expect(pipe.name).toEqual('someOtherName');
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {DirectiveResolver} from '@angular/compiler';
|
||||
import {AnimationEntryMetadata, Compiler, ComponentMetadata, DirectiveMetadata, Injectable, Injector, Provider, Type, resolveForwardRef} from '@angular/core';
|
||||
import {AnimationEntryMetadata, Compiler, Component, Directive, Injectable, Injector, Provider, Type, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {Map} from './facade/collection';
|
||||
import {isArray, isPresent} from './facade/lang';
|
||||
|
@ -20,7 +20,7 @@ import {ViewMetadata} from './private_import_core';
|
|||
*/
|
||||
@Injectable()
|
||||
export class MockDirectiveResolver extends DirectiveResolver {
|
||||
private _directives = new Map<Type<any>, DirectiveMetadata>();
|
||||
private _directives = new Map<Type<any>, Directive>();
|
||||
private _providerOverrides = new Map<Type<any>, any[]>();
|
||||
private _viewProviderOverrides = new Map<Type<any>, any[]>();
|
||||
private _views = new Map<Type<any>, ViewMetadata>();
|
||||
|
@ -33,7 +33,7 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
|||
|
||||
private _clearCacheFor(component: Type<any>) { this._compiler.clearCacheFor(component); }
|
||||
|
||||
resolve(type: Type<any>, throwIfNotFound = true): DirectiveMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): Directive {
|
||||
let metadata = this._directives.get(type);
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
|
@ -52,7 +52,7 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
|||
providers = originalViewProviders.concat(providerOverrides);
|
||||
}
|
||||
|
||||
if (metadata instanceof ComponentMetadata) {
|
||||
if (metadata instanceof Component) {
|
||||
let viewProviders = metadata.viewProviders;
|
||||
if (isPresent(viewProviderOverrides)) {
|
||||
const originalViewProviders: Provider[] =
|
||||
|
@ -80,7 +80,7 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
|||
inlineTemplate = view.template;
|
||||
}
|
||||
|
||||
return new ComponentMetadata({
|
||||
return new Component({
|
||||
selector: metadata.selector,
|
||||
inputs: metadata.inputs,
|
||||
outputs: metadata.outputs,
|
||||
|
@ -102,7 +102,7 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
|||
});
|
||||
}
|
||||
|
||||
return new DirectiveMetadata({
|
||||
return new Directive({
|
||||
selector: metadata.selector,
|
||||
inputs: metadata.inputs,
|
||||
outputs: metadata.outputs,
|
||||
|
@ -114,9 +114,9 @@ export class MockDirectiveResolver extends DirectiveResolver {
|
|||
}
|
||||
|
||||
/**
|
||||
* Overrides the {@link DirectiveMetadata} for a directive.
|
||||
* Overrides the {@link Directive} for a directive.
|
||||
*/
|
||||
setDirective(type: Type<any>, metadata: DirectiveMetadata): void {
|
||||
setDirective(type: Type<any>, metadata: Directive): void {
|
||||
this._directives.set(type, metadata);
|
||||
this._clearCacheFor(type);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ export * from './directive_resolver_mock';
|
|||
export * from './ng_module_resolver_mock';
|
||||
export * from './pipe_resolver_mock';
|
||||
|
||||
import {createPlatformFactory, ModuleWithComponentFactories, Injectable, CompilerOptions, COMPILER_OPTIONS, CompilerFactory, NgModuleFactory, Injector, NgModuleMetadata, NgModule, ComponentMetadata, Component, DirectiveMetadata, Directive, Pipe, Type, PlatformRef} from '@angular/core';
|
||||
import {createPlatformFactory, ModuleWithComponentFactories, Injectable, CompilerOptions, COMPILER_OPTIONS, CompilerFactory, NgModuleFactory, Injector, NgModule, Component, Directive, Pipe, Type, PlatformRef} from '@angular/core';
|
||||
import {MetadataOverride} from '@angular/core/testing';
|
||||
import {TestingCompilerFactory, TestingCompiler} from './private_import_core';
|
||||
import {platformCoreDynamic, RuntimeCompiler, DirectiveResolver, NgModuleResolver, PipeResolver} from '@angular/compiler';
|
||||
|
@ -73,17 +73,17 @@ export class TestingCompilerImpl implements TestingCompiler {
|
|||
overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): void {
|
||||
const oldMetadata = this._moduleResolver.resolve(ngModule, false);
|
||||
this._moduleResolver.setNgModule(
|
||||
ngModule, this._overrider.overrideMetadata(NgModuleMetadata, oldMetadata, override));
|
||||
ngModule, this._overrider.overrideMetadata(NgModule, oldMetadata, override));
|
||||
}
|
||||
overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): void {
|
||||
const oldMetadata = this._directiveResolver.resolve(directive, false);
|
||||
this._directiveResolver.setDirective(
|
||||
directive, this._overrider.overrideMetadata(DirectiveMetadata, oldMetadata, override));
|
||||
directive, this._overrider.overrideMetadata(Directive, oldMetadata, override));
|
||||
}
|
||||
overrideComponent(component: Type<any>, override: MetadataOverride<Component>): void {
|
||||
const oldMetadata = this._directiveResolver.resolve(component, false);
|
||||
this._directiveResolver.setDirective(
|
||||
component, this._overrider.overrideMetadata(ComponentMetadata, oldMetadata, override));
|
||||
component, this._overrider.overrideMetadata(Component, oldMetadata, override));
|
||||
}
|
||||
overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): void {
|
||||
const oldMetadata = this._pipeResolver.resolve(pipe, false);
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
*/
|
||||
|
||||
import {NgModuleResolver} from '@angular/compiler';
|
||||
import {Compiler, Injectable, Injector, NgModuleMetadata, Type} from '@angular/core';
|
||||
import {Compiler, Injectable, Injector, NgModule, Type} from '@angular/core';
|
||||
|
||||
import {Map} from './facade/collection';
|
||||
|
||||
@Injectable()
|
||||
export class MockNgModuleResolver extends NgModuleResolver {
|
||||
private _ngModules = new Map<Type<any>, NgModuleMetadata>();
|
||||
private _ngModules = new Map<Type<any>, NgModule>();
|
||||
|
||||
constructor(private _injector: Injector) { super(); }
|
||||
|
||||
|
@ -22,20 +22,20 @@ export class MockNgModuleResolver extends NgModuleResolver {
|
|||
private _clearCacheFor(component: Type<any>) { this._compiler.clearCacheFor(component); }
|
||||
|
||||
/**
|
||||
* Overrides the {@link NgModuleMetadata} for a module.
|
||||
* Overrides the {@link NgModule} for a module.
|
||||
*/
|
||||
setNgModule(type: Type<any>, metadata: NgModuleMetadata): void {
|
||||
setNgModule(type: Type<any>, metadata: NgModule): void {
|
||||
this._ngModules.set(type, metadata);
|
||||
this._clearCacheFor(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link NgModuleMetadata} for a module:
|
||||
* - Set the {@link NgModuleMetadata} to the overridden view when it exists or fallback to the
|
||||
* Returns the {@link NgModule} for a module:
|
||||
* - Set the {@link NgModule} to the overridden view when it exists or fallback to the
|
||||
* default
|
||||
* `NgModuleResolver`, see `setNgModule`.
|
||||
*/
|
||||
resolve(type: Type<any>, throwIfNotFound = true): NgModuleMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): NgModule {
|
||||
var metadata = this._ngModules.get(type);
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
*/
|
||||
|
||||
import {PipeResolver} from '@angular/compiler';
|
||||
import {Compiler, Injectable, Injector, PipeMetadata, Type} from '@angular/core';
|
||||
import {Compiler, Injectable, Injector, Pipe, Type} from '@angular/core';
|
||||
|
||||
import {Map} from './facade/collection';
|
||||
|
||||
@Injectable()
|
||||
export class MockPipeResolver extends PipeResolver {
|
||||
private _pipes = new Map<Type<any>, PipeMetadata>();
|
||||
private _pipes = new Map<Type<any>, Pipe>();
|
||||
|
||||
constructor(private _injector: Injector) { super(); }
|
||||
|
||||
|
@ -22,20 +22,20 @@ export class MockPipeResolver extends PipeResolver {
|
|||
private _clearCacheFor(pipe: Type<any>) { this._compiler.clearCacheFor(pipe); }
|
||||
|
||||
/**
|
||||
* Overrides the {@link PipeMetadata} for a pipe.
|
||||
* Overrides the {@link Pipe} for a pipe.
|
||||
*/
|
||||
setPipe(type: Type<any>, metadata: PipeMetadata): void {
|
||||
setPipe(type: Type<any>, metadata: Pipe): void {
|
||||
this._pipes.set(type, metadata);
|
||||
this._clearCacheFor(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link PipeMetadata} for a pipe:
|
||||
* - Set the {@link PipeMetadata} to the overridden view when it exists or fallback to the
|
||||
* Returns the {@link Pipe} for a pipe:
|
||||
* - Set the {@link Pipe} to the overridden view when it exists or fallback to the
|
||||
* default
|
||||
* `PipeResolver`, see `setPipe`.
|
||||
*/
|
||||
resolve(type: Type<any>, throwIfNotFound = true): PipeMetadata {
|
||||
resolve(type: Type<any>, throwIfNotFound = true): Pipe {
|
||||
var metadata = this._pipes.get(type);
|
||||
if (!metadata) {
|
||||
metadata = super.resolve(type, throwIfNotFound);
|
||||
|
|
|
@ -132,7 +132,7 @@ export class AnimationGroupMetadata extends AnimationWithStepsMetadata {
|
|||
* `animate` is an animation-specific function that is designed to be used inside of Angular2's
|
||||
* animation
|
||||
* DSL language. If this information is new, please navigate to the
|
||||
* {@link ComponentMetadata#animations-anchor component animations metadata
|
||||
* {@link Component#animations-anchor component animations metadata
|
||||
* page} to gain a better understanding of how animations in Angular2 are used.
|
||||
*
|
||||
* `animate` specifies an animation step that will apply the provided `styles` data for a given
|
||||
|
@ -195,7 +195,7 @@ export function animate(
|
|||
* `group` is an animation-specific function that is designed to be used inside of Angular2's
|
||||
* animation
|
||||
* DSL language. If this information is new, please navigate to the
|
||||
* {@link ComponentMetadata#animations-anchor component animations metadata
|
||||
* {@link Component#animations-anchor component animations metadata
|
||||
* page} to gain a better understanding of how animations in Angular2 are used.
|
||||
*
|
||||
* `group` specifies a list of animation steps that are all run in parallel. Grouped animations
|
||||
|
@ -237,7 +237,7 @@ export function group(steps: AnimationMetadata[]): AnimationGroupMetadata {
|
|||
* `sequence` is an animation-specific function that is designed to be used inside of Angular2's
|
||||
* animation
|
||||
* DSL language. If this information is new, please navigate to the
|
||||
* {@link ComponentMetadata#animations-anchor component animations metadata
|
||||
* {@link Component#animations-anchor component animations metadata
|
||||
* page} to gain a better understanding of how animations in Angular2 are used.
|
||||
*
|
||||
* `sequence` Specifies a list of animation steps that are run one by one. (`sequence` is used
|
||||
|
@ -280,7 +280,7 @@ export function sequence(steps: AnimationMetadata[]): AnimationSequenceMetadata
|
|||
* `style` is an animation-specific function that is designed to be used inside of Angular2's
|
||||
* animation
|
||||
* DSL language. If this information is new, please navigate to the
|
||||
* {@link ComponentMetadata#animations-anchor component animations metadata
|
||||
* {@link Component#animations-anchor component animations metadata
|
||||
* page} to gain a better understanding of how animations in Angular2 are used.
|
||||
*
|
||||
* `style` declares a key/value object containing CSS properties/styles that can then
|
||||
|
@ -350,7 +350,7 @@ export function style(
|
|||
* `state` is an animation-specific function that is designed to be used inside of Angular2's
|
||||
* animation
|
||||
* DSL language. If this information is new, please navigate to the
|
||||
* {@link ComponentMetadata#animations-anchor component animations metadata
|
||||
* {@link Component#animations-anchor component animations metadata
|
||||
* page} to gain a better understanding of how animations in Angular2 are used.
|
||||
*
|
||||
* `state` declares an animation state within the given trigger. When a state is
|
||||
|
@ -409,7 +409,7 @@ export function state(
|
|||
* `keyframes` is an animation-specific function that is designed to be used inside of Angular2's
|
||||
* animation
|
||||
* DSL language. If this information is new, please navigate to the
|
||||
* {@link ComponentMetadata#animations-anchor component animations metadata
|
||||
* {@link Component#animations-anchor component animations metadata
|
||||
* page} to gain a better understanding of how animations in Angular2 are used.
|
||||
*
|
||||
* `keyframes` specifies a collection of {@link style style} entries each optionally characterized
|
||||
|
@ -462,7 +462,7 @@ export function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSe
|
|||
* `transition` is an animation-specific function that is designed to be used inside of Angular2's
|
||||
* animation
|
||||
* DSL language. If this information is new, please navigate to the
|
||||
* {@link ComponentMetadata#animations-anchor component animations metadata
|
||||
* {@link Component#animations-anchor component animations metadata
|
||||
* page} to gain a better understanding of how animations in Angular2 are used.
|
||||
*
|
||||
* `transition` declares the {@link sequence sequence of animation steps} that will be run when the
|
||||
|
@ -557,7 +557,7 @@ export function transition(stateChangeExpr: string, steps: AnimationMetadata | A
|
|||
* `trigger` is an animation-specific function that is designed to be used inside of Angular2's
|
||||
* animation
|
||||
* DSL language. If this information is new, please navigate to the
|
||||
* {@link ComponentMetadata#animations-anchor component animations metadata
|
||||
* {@link Component#animations-anchor component animations metadata
|
||||
* page} to gain a better understanding of how animations in Angular2 are used.
|
||||
*
|
||||
* `trigger` Creates an animation trigger which will a list of {@link state state} and {@link
|
||||
|
@ -565,7 +565,7 @@ export function transition(stateChangeExpr: string, steps: AnimationMetadata | A
|
|||
* entries that will be evaluated when the expression bound to the trigger changes.
|
||||
*
|
||||
* Triggers are registered within the component annotation data under the
|
||||
* {@link ComponentMetadata#animations-anchor animations section}. An animation trigger can
|
||||
* {@link Component#animations-anchor animations section}. An animation trigger can
|
||||
* be placed on an element within a template by referencing the name of the
|
||||
* trigger followed by the expression value that the trigger is bound to
|
||||
* (in the form of `[@triggerName]="expression"`.
|
||||
|
|
|
@ -29,7 +29,7 @@ export function devModeEqual(a: any, b: any): boolean {
|
|||
}
|
||||
|
||||
/**
|
||||
* Indicates that the result of a {@link PipeMetadata} transformation has changed even though the
|
||||
* Indicates that the result of a {@link Pipe} transformation has changed even though the
|
||||
* reference
|
||||
* has not changed.
|
||||
*
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {OptionalMetadata, Provider, SkipSelfMetadata} from '../../di';
|
||||
import {Optional, Provider, SkipSelf} from '../../di';
|
||||
import {ListWrapper} from '../../facade/collection';
|
||||
import {getTypeNameForDebugging, isBlank, isPresent} from '../../facade/lang';
|
||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
|
@ -91,7 +91,7 @@ export class IterableDiffers {
|
|||
return IterableDiffers.create(factories, parent);
|
||||
},
|
||||
// Dependency technically isn't optional, but we can provide a better error message this way.
|
||||
deps: [[IterableDiffers, new SkipSelfMetadata(), new OptionalMetadata()]]
|
||||
deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {OptionalMetadata, Provider, SkipSelfMetadata} from '../../di';
|
||||
import {Optional, Provider, SkipSelf} from '../../di';
|
||||
import {ListWrapper} from '../../facade/collection';
|
||||
import {isBlank, isPresent} from '../../facade/lang';
|
||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
|
@ -81,7 +81,7 @@ export class KeyValueDiffers {
|
|||
return KeyValueDiffers.create(factories, parent);
|
||||
},
|
||||
// Dependency technically isn't optional, but we can provide a better error message this way.
|
||||
deps: [[KeyValueDiffers, new SkipSelfMetadata(), new OptionalMetadata()]]
|
||||
deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import {makeParamDecorator} from '../util/decorators';
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface InjectMetadataFactory {
|
||||
export interface InjectDecorator {
|
||||
/**
|
||||
* A parameter metadata that specifies a dependency.
|
||||
*
|
||||
|
@ -74,7 +74,7 @@ export interface Inject { token: any; }
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Inject: InjectMetadataFactory = makeParamDecorator([['token', undefined]]);
|
||||
export const Inject: InjectDecorator = makeParamDecorator([['token', undefined]]);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -82,7 +82,7 @@ export const Inject: InjectMetadataFactory = makeParamDecorator([['token', undef
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface OptionalMetadataFactory {
|
||||
export interface OptionalDecorator {
|
||||
/**
|
||||
* A parameter metadata that marks a dependency as optional. {@link Injector} provides `null` if
|
||||
* the dependency is not found.
|
||||
|
@ -122,14 +122,14 @@ export interface Optional {}
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Optional: OptionalMetadataFactory = makeParamDecorator([]);
|
||||
export const Optional: OptionalDecorator = makeParamDecorator([]);
|
||||
|
||||
/**
|
||||
* Type of the Injectable decorator / constructor function.
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface InjectableMetadataFactory {
|
||||
export interface InjectableDecorator {
|
||||
/**
|
||||
* A marker metadata that marks a class as available to {@link Injector} for creation.
|
||||
*
|
||||
|
@ -179,14 +179,14 @@ export interface Injectable {}
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Injectable: InjectableMetadataFactory = makeParamDecorator([]);
|
||||
export const Injectable: InjectableDecorator = makeParamDecorator([]);
|
||||
|
||||
/**
|
||||
* Type of the Self decorator / constructor function.
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface SelfMetadataFactory {
|
||||
export interface SelfDecorator {
|
||||
/**
|
||||
* Specifies that an {@link Injector} should retrieve a dependency only from itself.
|
||||
*
|
||||
|
@ -232,7 +232,7 @@ export interface Self {}
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Self: SelfMetadataFactory = makeParamDecorator([]);
|
||||
export const Self: SelfDecorator = makeParamDecorator([]);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -240,7 +240,7 @@ export const Self: SelfMetadataFactory = makeParamDecorator([]);
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface SkipSelfMetadataFactory {
|
||||
export interface SkipSelfDecorator {
|
||||
/**
|
||||
* Specifies that the dependency resolution should start from the parent injector.
|
||||
*
|
||||
|
@ -284,14 +284,14 @@ export interface SkipSelf {}
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const SkipSelf: SkipSelfMetadataFactory = makeParamDecorator([]);
|
||||
export const SkipSelf: SkipSelfDecorator = makeParamDecorator([]);
|
||||
|
||||
/**
|
||||
* Type of the Host decorator / constructor function.
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface HostMetadataFactory {
|
||||
export interface HostDecorator {
|
||||
/**
|
||||
* Specifies that an injector should retrieve a dependency from any injector until reaching the
|
||||
* closest host.
|
||||
|
@ -362,14 +362,4 @@ export interface Host {}
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Host: HostMetadataFactory = makeParamDecorator([]);
|
||||
|
||||
// TODO(tbosch): remove this
|
||||
export {
|
||||
Host as HostMetadata,
|
||||
Inject as InjectMetadata,
|
||||
Injectable as InjectableMetadata,
|
||||
Optional as OptionalMetadata,
|
||||
Self as SelfMetadata,
|
||||
SkipSelf as SkipSelfMetadata
|
||||
};
|
||||
export const Host: HostDecorator = makeParamDecorator([]);
|
||||
|
|
|
@ -11,7 +11,7 @@ import {unimplemented} from '../facade/errors';
|
|||
import {Type} from '../type';
|
||||
|
||||
import {Injector, THROW_IF_NOT_FOUND} from './injector';
|
||||
import {SelfMetadata, SkipSelfMetadata} from './metadata';
|
||||
import {Self, SkipSelf} from './metadata';
|
||||
import {Provider} from './provider';
|
||||
import {AbstractProviderError, CyclicDependencyError, InstantiationError, NoProviderError, OutOfBoundsError} from './reflective_errors';
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
|
@ -807,7 +807,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
|||
return this;
|
||||
}
|
||||
|
||||
if (upperBoundVisibility instanceof SelfMetadata) {
|
||||
if (upperBoundVisibility instanceof Self) {
|
||||
return this._getByKeySelf(key, notFoundValue);
|
||||
|
||||
} else {
|
||||
|
@ -834,7 +834,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
|||
_getByKeyDefault(key: ReflectiveKey, notFoundValue: any, lowerBoundVisibility: Object): any {
|
||||
var inj: Injector;
|
||||
|
||||
if (lowerBoundVisibility instanceof SkipSelfMetadata) {
|
||||
if (lowerBoundVisibility instanceof SkipSelf) {
|
||||
inj = this._parent;
|
||||
} else {
|
||||
inj = this;
|
||||
|
|
|
@ -12,7 +12,7 @@ import {reflector} from '../reflection/reflection';
|
|||
import {Type} from '../type';
|
||||
|
||||
import {resolveForwardRef} from './forward_ref';
|
||||
import {HostMetadata, InjectMetadata, OptionalMetadata, SelfMetadata, SkipSelfMetadata} from './metadata';
|
||||
import {Host, Inject, Optional, Self, SkipSelf} from './metadata';
|
||||
import {ClassProvider, ExistingProvider, FactoryProvider, Provider, TypeProvider, ValueProvider} from './provider';
|
||||
import {InvalidProviderError, MixingMultiProvidersWithRegularProvidersError, NoAnnotationError} from './reflective_errors';
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
|
@ -226,7 +226,7 @@ function _extractToken(
|
|||
var optional = false;
|
||||
|
||||
if (!isArray(metadata)) {
|
||||
if (metadata instanceof InjectMetadata) {
|
||||
if (metadata instanceof Inject) {
|
||||
return _createDependency(metadata.token, optional, null, null, depProps);
|
||||
} else {
|
||||
return _createDependency(metadata, optional, null, null, depProps);
|
||||
|
@ -242,19 +242,19 @@ function _extractToken(
|
|||
if (paramMetadata instanceof Type) {
|
||||
token = paramMetadata;
|
||||
|
||||
} else if (paramMetadata instanceof InjectMetadata) {
|
||||
} else if (paramMetadata instanceof Inject) {
|
||||
token = paramMetadata.token;
|
||||
|
||||
} else if (paramMetadata instanceof OptionalMetadata) {
|
||||
} else if (paramMetadata instanceof Optional) {
|
||||
optional = true;
|
||||
|
||||
} else if (paramMetadata instanceof SelfMetadata) {
|
||||
} else if (paramMetadata instanceof Self) {
|
||||
upperBoundVisibility = paramMetadata;
|
||||
|
||||
} else if (paramMetadata instanceof HostMetadata) {
|
||||
} else if (paramMetadata instanceof Host) {
|
||||
upperBoundVisibility = paramMetadata;
|
||||
|
||||
} else if (paramMetadata instanceof SkipSelfMetadata) {
|
||||
} else if (paramMetadata instanceof SkipSelf) {
|
||||
lowerBoundVisibility = paramMetadata;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import {getSymbolIterator} from '../facade/lang';
|
|||
* An unmodifiable list of items that Angular keeps up to date when the state
|
||||
* of the application changes.
|
||||
*
|
||||
* The type of object that {@link QueryMetadata} and {@link ViewQueryMetadata} provide.
|
||||
* The type of object that {@link Query} and {@link ViewQueryMetadata} provide.
|
||||
*
|
||||
* Implements an iterable interface, therefore it can be used in both ES6
|
||||
* javascript `for (var i of items)` loops as well as in Angular templates with
|
||||
|
|
|
@ -23,21 +23,3 @@ export {Component, Directive, HostBinding, HostListener, Input, Output, Pipe} fr
|
|||
export {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit} from './metadata/lifecycle_hooks';
|
||||
export {CUSTOM_ELEMENTS_SCHEMA, ModuleWithProviders, NO_ERRORS_SCHEMA, NgModule, SchemaMetadata} from './metadata/ng_module';
|
||||
export {ViewEncapsulation} from './metadata/view';
|
||||
|
||||
|
||||
|
||||
// TODO(vicb): delete ?
|
||||
export {Directive as DirectiveMetadata};
|
||||
export {Component as ComponentMetadata};
|
||||
export {NgModule as NgModuleMetadata};
|
||||
export {Pipe as PipeMetadata};
|
||||
export {Output as OutputMetadata};
|
||||
export {Input as InputMetadata};
|
||||
export {HostBinding as HostBindingMetadata};
|
||||
export {HostListener as HostListenerMetadata};
|
||||
export {Attribute as AttributeMetadata};
|
||||
export {ContentChildren as ContentChildrenMetadata};
|
||||
export {ContentChild as ContentChildMetadata};
|
||||
export {ViewChildren as ViewChildrenMetadata};
|
||||
export {ViewChild as ViewChildMetadata};
|
||||
export {Query as QueryMetadata};
|
||||
|
|
|
@ -54,7 +54,7 @@ export const ANALYZE_FOR_ENTRY_COMPONENTS = new OpaqueToken('AnalyzeForEntryComp
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface AttributeMetadataFactory {
|
||||
export interface AttributeDecorator {
|
||||
/**
|
||||
* Specifies that a constant attribute value should be injected.
|
||||
*
|
||||
|
@ -122,8 +122,7 @@ export interface Attribute { attributeName?: string; }
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Attribute: AttributeMetadataFactory =
|
||||
makeParamDecorator([['attributeName', undefined]]);
|
||||
export const Attribute: AttributeDecorator = makeParamDecorator([['attributeName', undefined]]);
|
||||
|
||||
/**
|
||||
* Type of the Query metadata.
|
||||
|
@ -145,7 +144,7 @@ export abstract class Query {}
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface ContentChildrenMetadataFactory {
|
||||
export interface ContentChildrenDecorator {
|
||||
/**
|
||||
* Configures a content query.
|
||||
*
|
||||
|
@ -187,7 +186,7 @@ export type ContentChildren = Query;
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const ContentChildren: ContentChildrenMetadataFactory = makePropDecorator(
|
||||
export const ContentChildren: ContentChildrenDecorator = makePropDecorator(
|
||||
[
|
||||
['selector', undefined],
|
||||
{first: false, isViewQuery: false, descendants: false, read: undefined}
|
||||
|
@ -199,7 +198,7 @@ export const ContentChildren: ContentChildrenMetadataFactory = makePropDecorator
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface ContentChildMetadataFactory {
|
||||
export interface ContentChildDecorator {
|
||||
/**
|
||||
* Configures a content query.
|
||||
*
|
||||
|
@ -246,7 +245,7 @@ export type ContentChild = Query;
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const ContentChild: ContentChildMetadataFactory = makePropDecorator(
|
||||
export const ContentChild: ContentChildDecorator = makePropDecorator(
|
||||
[
|
||||
['selector', undefined], {
|
||||
first: true,
|
||||
|
@ -258,11 +257,11 @@ export const ContentChild: ContentChildMetadataFactory = makePropDecorator(
|
|||
Query);
|
||||
|
||||
/**
|
||||
* Type of the ViewChildrenMetadataFactory decorator / constructor function.
|
||||
* Type of the ViewChildren decorator / constructor function.
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface ViewChildrenMetadataFactory {
|
||||
export interface ViewChildrenDecorator {
|
||||
/**
|
||||
* Declares a list of child element references.
|
||||
*
|
||||
|
@ -357,7 +356,7 @@ export type ViewChildren = Query;
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const ViewChildren: ViewChildrenMetadataFactory = makePropDecorator(
|
||||
export const ViewChildren: ViewChildrenDecorator = makePropDecorator(
|
||||
[
|
||||
['selector', undefined], {
|
||||
first: false,
|
||||
|
@ -370,11 +369,11 @@ export const ViewChildren: ViewChildrenMetadataFactory = makePropDecorator(
|
|||
|
||||
|
||||
/**
|
||||
* Type of the ViewChildMetadataFactory decorator / constructor function.
|
||||
* Type of the ViewChild decorator / constructor function.
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface ViewChildMetadataFactory {
|
||||
export interface ViewChildDecorator {
|
||||
/**
|
||||
*
|
||||
* Declares a reference of child element.
|
||||
|
@ -462,7 +461,7 @@ export type ViewChild = Query;
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const ViewChild: ViewChildMetadataFactory = makePropDecorator(
|
||||
export const ViewChild: ViewChildDecorator = makePropDecorator(
|
||||
[
|
||||
['selector', undefined], {
|
||||
first: true,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {AnimationEntryMetadata} from '../animation/metadata';
|
||||
import {ChangeDetectionStrategy} from '../change_detection/constants';
|
||||
import {InjectableMetadata, Provider} from '../di';
|
||||
import {Injectable, Provider} from '../di';
|
||||
import {isPresent} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
import {TypeDecorator, makeDecorator, makePropDecorator} from '../util/decorators';
|
||||
|
@ -21,11 +21,11 @@ import {ViewEncapsulation} from './view';
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface DirectiveMetadataFactory {
|
||||
export interface DirectiveDecorator {
|
||||
/**
|
||||
* Directives allow you to attach behavior to elements in the DOM.
|
||||
*
|
||||
* {@link DirectiveMetadata}s with an embedded view are called {@link ComponentMetadata}s.
|
||||
* {@link Directive}s with an embedded view are called {@link Component}s.
|
||||
*
|
||||
* A directive consists of a single directive annotation and a controller class. When the
|
||||
* directive's `selector` matches
|
||||
|
@ -59,7 +59,7 @@ export interface DirectiveMetadataFactory {
|
|||
*
|
||||
* Angular then resolves dependencies as follows, according to the order in which they appear in
|
||||
* the
|
||||
* {@link ComponentMetadata}:
|
||||
* {@link Component}:
|
||||
*
|
||||
* 1. Dependencies on the current element
|
||||
* 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM
|
||||
|
@ -85,7 +85,7 @@ export interface DirectiveMetadataFactory {
|
|||
* To inject element-specific special objects, declare the constructor parameter as:
|
||||
* - `element: ElementRef` to obtain a reference to logical element in the view.
|
||||
* - `viewContainer: ViewContainerRef` to control child template instantiation, for
|
||||
* {@link DirectiveMetadata} directives only
|
||||
* {@link Directive} directives only
|
||||
* - `bindingPropagation: BindingPropagation` to control change detection in a more granular way.
|
||||
*
|
||||
* ### Example
|
||||
|
@ -311,7 +311,7 @@ export interface DirectiveMetadataFactory {
|
|||
* location in the current view
|
||||
* where these actions are performed.
|
||||
*
|
||||
* Views are always created as children of the current {@link ComponentMetadata}, and as siblings
|
||||
* Views are always created as children of the current {@link Component}, and as siblings
|
||||
* of
|
||||
* the
|
||||
* `<template>` element. Thus a
|
||||
|
@ -770,7 +770,7 @@ export interface Directive {
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Directive: DirectiveMetadataFactory = <DirectiveMetadataFactory>makeDecorator({
|
||||
export const Directive: DirectiveDecorator = <DirectiveDecorator>makeDecorator({
|
||||
selector: undefined,
|
||||
inputs: undefined,
|
||||
outputs: undefined,
|
||||
|
@ -785,7 +785,7 @@ export const Directive: DirectiveMetadataFactory = <DirectiveMetadataFactory>mak
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface ComponentMetadataFactory {
|
||||
export interface ComponentDecorator {
|
||||
/**
|
||||
* Declare reusable UI building blocks for an application.
|
||||
*
|
||||
|
@ -1050,7 +1050,7 @@ export interface Component extends Directive {
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Component: ComponentMetadataFactory = <ComponentMetadataFactory>makeDecorator(
|
||||
export const Component: ComponentDecorator = <ComponentDecorator>makeDecorator(
|
||||
{
|
||||
selector: undefined,
|
||||
inputs: undefined,
|
||||
|
@ -1078,7 +1078,7 @@ export const Component: ComponentMetadataFactory = <ComponentMetadataFactory>mak
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface PipeMetadataFactory {
|
||||
export interface PipeDecorator {
|
||||
/**
|
||||
* Declare reusable pipe function.
|
||||
*
|
||||
|
@ -1110,7 +1110,7 @@ export interface Pipe {
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Pipe: PipeMetadataFactory = <PipeMetadataFactory>makeDecorator({
|
||||
export const Pipe: PipeDecorator = <PipeDecorator>makeDecorator({
|
||||
name: undefined,
|
||||
pure: true,
|
||||
});
|
||||
|
@ -1121,13 +1121,13 @@ export const Pipe: PipeMetadataFactory = <PipeMetadataFactory>makeDecorator({
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface InputMetadataFactory {
|
||||
export interface InputDecorator {
|
||||
/**
|
||||
* Declares a data-bound input property.
|
||||
*
|
||||
* Angular automatically updates data-bound properties during change detection.
|
||||
*
|
||||
* `InputMetadata` takes an optional parameter that specifies the name
|
||||
* `Input` takes an optional parameter that specifies the name
|
||||
* used when instantiating a component in the template. When not provided,
|
||||
* the name of the decorated property is used.
|
||||
*
|
||||
|
@ -1184,21 +1184,21 @@ export interface Input {
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Input: InputMetadataFactory = makePropDecorator([['bindingPropertyName', undefined]]);
|
||||
export const Input: InputDecorator = makePropDecorator([['bindingPropertyName', undefined]]);
|
||||
|
||||
/**
|
||||
* Type of the Output decorator / constructor function.
|
||||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface OutputMetadataFactory {
|
||||
export interface OutputDecorator {
|
||||
/**
|
||||
* Declares an event-bound output property.
|
||||
*
|
||||
* When an output property emits an event, an event handler attached to that event
|
||||
* the template is invoked.
|
||||
*
|
||||
* `OutputMetadata` takes an optional parameter that specifies the name
|
||||
* `Output` takes an optional parameter that specifies the name
|
||||
* used when instantiating a component in the template. When not provided,
|
||||
* the name of the decorated property is used.
|
||||
*
|
||||
|
@ -1249,8 +1249,7 @@ export interface Output { bindingPropertyName?: string; }
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Output: OutputMetadataFactory =
|
||||
makePropDecorator([['bindingPropertyName', undefined]]);
|
||||
export const Output: OutputDecorator = makePropDecorator([['bindingPropertyName', undefined]]);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1258,14 +1257,14 @@ export const Output: OutputMetadataFactory =
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface HostBindingMetadataFactory {
|
||||
export interface HostBindingDecorator {
|
||||
/**
|
||||
* Declares a host property binding.
|
||||
*
|
||||
* Angular automatically checks host property bindings during change detection.
|
||||
* If a binding changes, it will update the host element of the directive.
|
||||
*
|
||||
* `HostBindingMetadata` takes an optional parameter that specifies the property
|
||||
* `HostBinding` takes an optional parameter that specifies the property
|
||||
* name of the host element that will be updated. When not provided,
|
||||
* the class property name is used.
|
||||
*
|
||||
|
@ -1310,7 +1309,7 @@ export interface HostBinding { hostPropertyName?: string; }
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const HostBinding: HostBindingMetadataFactory =
|
||||
export const HostBinding: HostBindingDecorator =
|
||||
makePropDecorator([['hostPropertyName', undefined]]);
|
||||
|
||||
|
||||
|
@ -1319,7 +1318,7 @@ export const HostBinding: HostBindingMetadataFactory =
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface HostListenerMetadataFactory {
|
||||
export interface HostListenerDecorator {
|
||||
/**
|
||||
* Declares a host listener.
|
||||
*
|
||||
|
@ -1374,5 +1373,5 @@ export interface HostListener {
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const HostListener: HostListenerMetadataFactory =
|
||||
export const HostListener: HostListenerDecorator =
|
||||
makePropDecorator([['eventName', undefined], ['args', []]]);
|
||||
|
|
|
@ -236,7 +236,7 @@ export abstract class DoCheck { abstract ngDoCheck(): void; }
|
|||
*
|
||||
*
|
||||
* To create a stateful Pipe, you should implement this interface and set the `pure`
|
||||
* parameter to `false` in the {@link PipeMetadata}.
|
||||
* parameter to `false` in the {@link Pipe}.
|
||||
*
|
||||
* A stateful pipe may produce different output, given the same input. It is
|
||||
* likely that a stateful pipe may contain state that should be cleaned up when
|
||||
|
|
|
@ -54,7 +54,7 @@ export const NO_ERRORS_SCHEMA: SchemaMetadata = {
|
|||
*
|
||||
* @stable
|
||||
*/
|
||||
export interface NgModuleMetadataFactory {
|
||||
export interface NgModuleDecorator {
|
||||
/**
|
||||
* Defines an NgModule.
|
||||
*/
|
||||
|
@ -191,7 +191,7 @@ export interface NgModule {
|
|||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const NgModule: NgModuleMetadataFactory = <NgModuleMetadataFactory>makeDecorator({
|
||||
export const NgModule: NgModuleDecorator = <NgModuleDecorator>makeDecorator({
|
||||
providers: undefined,
|
||||
declarations: undefined,
|
||||
imports: undefined,
|
||||
|
|
|
@ -53,7 +53,7 @@ export var VIEW_ENCAPSULATION_VALUES =
|
|||
* When a component is instantiated, the template is loaded into the component's shadow root, and
|
||||
* the expressions and statements in the template are evaluated against the component.
|
||||
*
|
||||
* For details on the `@Component` annotation, see {@link ComponentMetadata}.
|
||||
* For details on the `@Component` annotation, see {@link Component}.
|
||||
*
|
||||
* ### Example
|
||||
*
|
||||
|
@ -72,7 +72,7 @@ export var VIEW_ENCAPSULATION_VALUES =
|
|||
* }
|
||||
* ```
|
||||
*
|
||||
* @deprecated Use ComponentMetadata instead.
|
||||
* @deprecated Use Component instead.
|
||||
*/
|
||||
export class ViewMetadata {
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Inject, InjectMetadata, Injectable, Injector, Optional, Provider, ReflectiveInjector, ReflectiveKey, SelfMetadata, forwardRef} from '@angular/core';
|
||||
import {Inject, Injectable, Injector, Optional, Provider, ReflectiveInjector, ReflectiveKey, Self, forwardRef} from '@angular/core';
|
||||
import {ReflectiveInjectorDynamicStrategy, ReflectiveInjectorInlineStrategy, ReflectiveInjector_, ReflectiveProtoInjector} from '@angular/core/src/di/reflective_injector';
|
||||
import {ResolvedReflectiveProvider_} from '@angular/core/src/di/reflective_provider';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
@ -423,11 +423,8 @@ export function main() {
|
|||
describe('@Self()', () => {
|
||||
it('should return a dependency from self', () => {
|
||||
var inj = ReflectiveInjector.resolveAndCreate([
|
||||
Engine, {
|
||||
provide: Car,
|
||||
useFactory: (e: Engine) => new Car(e),
|
||||
deps: [[Engine, new SelfMetadata()]]
|
||||
}
|
||||
Engine,
|
||||
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]}
|
||||
]);
|
||||
|
||||
expect(inj.get(Car)).toBeAnInstanceOf(Car);
|
||||
|
@ -435,11 +432,9 @@ export function main() {
|
|||
|
||||
it('should throw when not requested provider on self', () => {
|
||||
var parent = ReflectiveInjector.resolveAndCreate([Engine]);
|
||||
var child = parent.resolveAndCreateChild([{
|
||||
provide: Car,
|
||||
useFactory: (e: Engine) => new Car(e),
|
||||
deps: [[Engine, new SelfMetadata()]]
|
||||
}]);
|
||||
var child = parent.resolveAndCreateChild([
|
||||
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]}
|
||||
]);
|
||||
|
||||
expect(() => child.get(Car))
|
||||
.toThrowError(`No provider for Engine! (${stringify(Car)} -> ${stringify(Engine)})`);
|
||||
|
@ -536,7 +531,7 @@ export function main() {
|
|||
var providers = ReflectiveInjector.resolve([{
|
||||
provide: 'token',
|
||||
useFactory: (e: any /** TODO #9100 */) => 'result',
|
||||
deps: [[new InjectMetadata('dep')]]
|
||||
deps: [[new Inject('dep')]]
|
||||
}]);
|
||||
|
||||
var provider = providers[0];
|
||||
|
@ -546,9 +541,9 @@ export function main() {
|
|||
|
||||
it('should allow declaring dependencies with flat arrays', () => {
|
||||
var resolved = ReflectiveInjector.resolve(
|
||||
[{provide: 'token', useFactory: (e: any) => e, deps: [new InjectMetadata('dep')]}]);
|
||||
[{provide: 'token', useFactory: (e: any) => e, deps: [new Inject('dep')]}]);
|
||||
var nestedResolved = ReflectiveInjector.resolve(
|
||||
[{provide: 'token', useFactory: (e: any) => e, deps: [[new InjectMetadata('dep')]]}]);
|
||||
[{provide: 'token', useFactory: (e: any) => e, deps: [[new Inject('dep')]]}]);
|
||||
expect(resolved[0].resolvedFactories[0].dependencies[0].key.token)
|
||||
.toEqual(nestedResolved[0].resolvedFactories[0].dependencies[0].key.token);
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {ElementSchemaRegistry} from '@angular/compiler/src/schema/element_schema_registry';
|
||||
import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/testing/test_bindings';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ComponentMetadata, DebugElement, Directive, DoCheck, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, Type, ViewContainerRef, WrappedValue, forwardRef} from '@angular/core';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, DoCheck, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, Type, ViewContainerRef, WrappedValue, forwardRef} from '@angular/core';
|
||||
import {DebugDomRenderer} from '@angular/core/src/debug/debug_renderer';
|
||||
import {ComponentFixture, TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
|
@ -29,7 +29,7 @@ export function main() {
|
|||
function createCompFixture<T>(template: string, compType: Type<T>): ComponentFixture<T>;
|
||||
function createCompFixture<T>(
|
||||
template: string, compType: Type<T> = <any>TestComponent): ComponentFixture<T> {
|
||||
TestBed.overrideComponent(compType, {set: new ComponentMetadata({template})});
|
||||
TestBed.overrideComponent(compType, {set: new Component({template})});
|
||||
|
||||
initHelpers();
|
||||
|
||||
|
@ -655,7 +655,7 @@ export function main() {
|
|||
describe('lifecycle', () => {
|
||||
function createCompWithContentAndViewChild(): ComponentFixture<any> {
|
||||
TestBed.overrideComponent(AnotherComponent, {
|
||||
set: new ComponentMetadata({
|
||||
set: new Component({
|
||||
selector: 'other-cmp',
|
||||
template: '<div testDirective="viewChild"></div>',
|
||||
})
|
||||
|
@ -1003,7 +1003,7 @@ export function main() {
|
|||
|
||||
it('should be called after processing the content and view children', fakeAsync(() => {
|
||||
TestBed.overrideComponent(AnotherComponent, {
|
||||
set: new ComponentMetadata(
|
||||
set: new Component(
|
||||
{selector: 'other-cmp', template: '<div testDirective="viewChild"></div>'})
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {ComponentFactory, Host, Inject, Injectable, Injector, NO_ERRORS_SCHEMA, NgModule, OnDestroy, OpaqueToken, ReflectiveInjector, SkipSelf, SkipSelfMetadata} from '@angular/core';
|
||||
import {ComponentFactory, Host, Inject, Injectable, Injector, NO_ERRORS_SCHEMA, NgModule, OnDestroy, OpaqueToken, ReflectiveInjector, SkipSelf} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, PipeTransform} from '@angular/core/src/change_detection/change_detection';
|
||||
import {ComponentFactoryResolver} from '@angular/core/src/linker/component_factory_resolver';
|
||||
import {ElementRef} from '@angular/core/src/linker/element_ref';
|
||||
|
@ -2045,9 +2045,7 @@ function createParentBus(peb: EventBus) {
|
|||
|
||||
@Component({
|
||||
selector: 'parent-providing-event-bus',
|
||||
providers: [
|
||||
{provide: EventBus, useFactory: createParentBus, deps: [[EventBus, new SkipSelfMetadata()]]}
|
||||
],
|
||||
providers: [{provide: EventBus, useFactory: createParentBus, deps: [[EventBus, new SkipSelf()]]}],
|
||||
template: `<child-consuming-event-bus></child-consuming-event-bus>`
|
||||
})
|
||||
class ParentProvidingEventBus {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, ComponentFactoryResolver, Directive, HostBinding, Inject, Injectable, Injector, Input, NgModule, NgModuleRef, Optional, Pipe, Provider, SelfMetadata, Type, forwardRef, getModuleFactory} from '@angular/core';
|
||||
import {ANALYZE_FOR_ENTRY_COMPONENTS, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, ComponentFactoryResolver, Directive, HostBinding, Inject, Injectable, Injector, Input, NgModule, NgModuleRef, Optional, Pipe, Provider, Self, Type, forwardRef, getModuleFactory} from '@angular/core';
|
||||
import {Console} from '@angular/core/src/console';
|
||||
import {ComponentFixture, TestBed, inject} from '@angular/core/testing';
|
||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||
|
@ -833,11 +833,8 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
describe('@Self()', () => {
|
||||
it('should return a dependency from self', () => {
|
||||
var inj = createInjector([
|
||||
Engine, {
|
||||
provide: Car,
|
||||
useFactory: (e: Engine) => new Car(e),
|
||||
deps: [[Engine, new SelfMetadata()]]
|
||||
}
|
||||
Engine,
|
||||
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]}
|
||||
]);
|
||||
|
||||
expect(inj.get(Car)).toBeAnInstanceOf(Car);
|
||||
|
@ -847,7 +844,7 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||
expect(() => createInjector([{
|
||||
provide: Car,
|
||||
useFactory: (e: Engine) => new Car(e),
|
||||
deps: [[Engine, new SelfMetadata()]]
|
||||
deps: [[Engine, new Self()]]
|
||||
}]))
|
||||
.toThrowError(/No provider for Engine/g);
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, ElementRef, Host, Inject, InjectMetadata, Input, Optional, Pipe, PipeTransform, Provider, Self, SkipSelfMetadata, TemplateRef, Type, ViewContainerRef, forwardRef} from '@angular/core';
|
||||
import {Attribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, Directive, ElementRef, Host, Inject, Input, Optional, Pipe, PipeTransform, Provider, Self, SkipSelf, TemplateRef, Type, ViewContainerRef, forwardRef} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||
import {beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
@ -266,7 +266,7 @@ export function main() {
|
|||
{provide: 'injectable1', useValue: 'new-injectable1'}, {
|
||||
provide: 'injectable2',
|
||||
useFactory: (val: any) => `${val}-injectable2`,
|
||||
deps: [[new InjectMetadata('injectable1'), new SkipSelfMetadata()]]
|
||||
deps: [[new Inject('injectable1'), new SkipSelf()]]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {DirectiveResolver} from '@angular/compiler';
|
||||
import {DirectiveMetadata, Type} from '@angular/core';
|
||||
import {Directive, Type} from '@angular/core';
|
||||
|
||||
var COMPONENT_SELECTOR = /^[\w|-]*$/;
|
||||
var SKEWER_CASE = /-(\w)/g;
|
||||
|
@ -32,7 +32,7 @@ export interface ComponentInfo {
|
|||
}
|
||||
|
||||
export function getComponentInfo(type: Type<any>): ComponentInfo {
|
||||
var resolvedMetadata: DirectiveMetadata = directiveResolver.resolve(type);
|
||||
var resolvedMetadata: Directive = directiveResolver.resolve(type);
|
||||
var selector = resolvedMetadata.selector;
|
||||
if (!selector.match(COMPONENT_SELECTOR)) {
|
||||
throw new Error('Only selectors matching element names are supported, got: ' + selector);
|
||||
|
|
Loading…
Reference in New Issue