feat(core): renam AMBIENT_DIRECTIVES and AMBIENT_PIPES into PLATFORM_DIRECTIVES and PLATFORM_PIPES
After discussing it we decided that PLATFORM_ is a better prefix for directives available everywhere in the app. BREAKING CHANGE AMBIENT_DIRECTIVES -> PLATFORM_DIRECTIVES AMBIENT_PIPES -> PLATFORM_PIPES Closes #5201
This commit is contained in:
@ -19,5 +19,5 @@ export * from './src/common/directives';
|
||||
export * from './src/common/forms';
|
||||
export * from './src/core/debug';
|
||||
export * from './src/core/change_detection';
|
||||
export * from './src/core/ambient';
|
||||
export * from './src/core/platform_directives_and_pipes';
|
||||
export * from './src/core/dev_mode';
|
||||
|
@ -6,7 +6,7 @@ export {
|
||||
CompileTemplateMetadata
|
||||
} from './directive_metadata';
|
||||
export {SourceModule, SourceWithImports} from './source_module';
|
||||
export {AMBIENT_DIRECTIVES, AMBIENT_PIPES} from 'angular2/src/core/ambient';
|
||||
export {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/src/core/platform_directives_and_pipes';
|
||||
|
||||
import {assertionsEnabled, Type} from 'angular2/src/facade/lang';
|
||||
import {provide, Provider} from 'angular2/src/core/di';
|
||||
|
@ -18,7 +18,7 @@ import {hasLifecycleHook} from 'angular2/src/core/linker/directive_lifecycle_ref
|
||||
import {LifecycleHooks, LIFECYCLE_HOOKS_VALUES} from 'angular2/src/core/linker/interfaces';
|
||||
import {reflector} from 'angular2/src/core/reflection/reflection';
|
||||
import {Injectable, Inject, Optional} from 'angular2/src/core/di';
|
||||
import {AMBIENT_DIRECTIVES} from 'angular2/src/core/ambient';
|
||||
import {PLATFORM_DIRECTIVES} from 'angular2/src/core/platform_directives_and_pipes';
|
||||
import {MODULE_SUFFIX} from './util';
|
||||
|
||||
@Injectable()
|
||||
@ -26,7 +26,7 @@ export class RuntimeMetadataResolver {
|
||||
private _cache = new Map<Type, cpl.CompileDirectiveMetadata>();
|
||||
|
||||
constructor(private _directiveResolver: DirectiveResolver, private _viewResolver: ViewResolver,
|
||||
@Optional() @Inject(AMBIENT_DIRECTIVES) private _ambientDirectives: Type[]) {}
|
||||
@Optional() @Inject(PLATFORM_DIRECTIVES) private _platformDirectives: Type[]) {}
|
||||
|
||||
getMetadata(directiveType: Type): cpl.CompileDirectiveMetadata {
|
||||
var meta = this._cache.get(directiveType);
|
||||
@ -69,7 +69,7 @@ export class RuntimeMetadataResolver {
|
||||
|
||||
getViewDirectivesMetadata(component: Type): cpl.CompileDirectiveMetadata[] {
|
||||
var view = this._viewResolver.resolve(component);
|
||||
var directives = flattenDirectives(view, this._ambientDirectives);
|
||||
var directives = flattenDirectives(view, this._platformDirectives);
|
||||
for (var i = 0; i < directives.length; i++) {
|
||||
if (!isValidDirective(directives[i])) {
|
||||
throw new BaseException(
|
||||
@ -87,10 +87,10 @@ function removeDuplicates(items: any[]): any[] {
|
||||
return MapWrapper.keys(m);
|
||||
}
|
||||
|
||||
function flattenDirectives(view: ViewMetadata, ambientDirectives: any[]): Type[] {
|
||||
function flattenDirectives(view: ViewMetadata, platformDirectives: any[]): Type[] {
|
||||
let directives = [];
|
||||
if (isPresent(ambientDirectives)) {
|
||||
flattenArray(ambientDirectives, directives);
|
||||
if (isPresent(platformDirectives)) {
|
||||
flattenArray(platformDirectives, directives);
|
||||
}
|
||||
if (isPresent(view.directives)) {
|
||||
flattenArray(view.directives, directives);
|
||||
|
@ -47,7 +47,7 @@ import {AppViewManager_} from "./linker/view_manager";
|
||||
import {Compiler_} from "./linker/compiler";
|
||||
import {wtfLeave, wtfCreateScope, WtfScopeFn} from './profile/profile';
|
||||
import {ChangeDetectorRef} from 'angular2/src/core/change_detection/change_detector_ref';
|
||||
import {AMBIENT_DIRECTIVES, AMBIENT_PIPES} from "angular2/src/core/ambient";
|
||||
import {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from "angular2/src/core/platform_directives_and_pipes";
|
||||
import {lockDevMode} from 'angular2/src/facade/lang';
|
||||
import {COMMON_DIRECTIVES, COMMON_PIPES} from "angular2/common";
|
||||
|
||||
@ -110,8 +110,8 @@ export function applicationCommonProviders(): Array<Type | Provider | any[]> {
|
||||
provide(KeyValueDiffers, {useValue: defaultKeyValueDiffers}),
|
||||
DirectiveResolver,
|
||||
PipeResolver,
|
||||
provide(AMBIENT_PIPES, {useValue: COMMON_PIPES, multi: true}),
|
||||
provide(AMBIENT_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
|
||||
provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
|
||||
provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
|
||||
provide(DynamicComponentLoader, {useClass: DynamicComponentLoader_})
|
||||
];
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import {DirectiveResolver} from './directive_resolver';
|
||||
import {ViewResolver} from './view_resolver';
|
||||
import {PipeResolver} from './pipe_resolver';
|
||||
import {ViewMetadata, ViewEncapsulation} from '../metadata/view';
|
||||
import {AMBIENT_PIPES} from 'angular2/src/core/ambient';
|
||||
import {PLATFORM_PIPES} from 'angular2/src/core/platform_directives_and_pipes';
|
||||
|
||||
import {
|
||||
visitAllCommands,
|
||||
@ -40,7 +40,7 @@ export class ProtoViewFactory {
|
||||
private _nextTemplateId: number = 0;
|
||||
|
||||
constructor(private _renderer: Renderer,
|
||||
@Optional() @Inject(AMBIENT_PIPES) private _ambientPipes: Array<Type | any[]>,
|
||||
@Optional() @Inject(PLATFORM_PIPES) private _platformPipes: Array<Type | any[]>,
|
||||
private _directiveResolver: DirectiveResolver, private _viewResolver: ViewResolver,
|
||||
private _pipeResolver: PipeResolver, @Inject(APP_ID) private _appId: string) {}
|
||||
|
||||
@ -119,8 +119,8 @@ export class ProtoViewFactory {
|
||||
|
||||
private _flattenPipes(view: ViewMetadata): any[] {
|
||||
let pipes = [];
|
||||
if (isPresent(this._ambientPipes)) {
|
||||
_flattenArray(this._ambientPipes, pipes);
|
||||
if (isPresent(this._platformPipes)) {
|
||||
_flattenArray(this._platformPipes, pipes);
|
||||
}
|
||||
if (isPresent(view.pipes)) {
|
||||
_flattenArray(view.pipes, pipes);
|
||||
|
@ -8,7 +8,7 @@ import {CONST_EXPR} from "angular2/src/facade/lang";
|
||||
* ### Example
|
||||
*
|
||||
* ```typescript
|
||||
* import {AMBIENT_DIRECTIVES} from 'angular2/angular2';
|
||||
* import {PLATFORM_DIRECTIVES} from 'angular2/angular2';
|
||||
* import {OtherDirective} from './myDirectives';
|
||||
*
|
||||
* @Component({
|
||||
@ -22,10 +22,10 @@ import {CONST_EXPR} from "angular2/src/facade/lang";
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* bootstrap(MyComponent, [provide(AMBIENT_DIRECTIVES, {useValue: [OtherDirective], multi:true})]);
|
||||
* bootstrap(MyComponent, [provide(PLATFORM_DIRECTIVES, {useValue: [OtherDirective], multi:true})]);
|
||||
* ```
|
||||
*/
|
||||
export const AMBIENT_DIRECTIVES: OpaqueToken = CONST_EXPR(new OpaqueToken("Ambient Directives"));
|
||||
export const PLATFORM_DIRECTIVES: OpaqueToken = CONST_EXPR(new OpaqueToken("Platform Directives"));
|
||||
|
||||
/**
|
||||
* A token that can be provided when bootstraping an application to make an array of pipes
|
||||
@ -34,7 +34,7 @@ export const AMBIENT_DIRECTIVES: OpaqueToken = CONST_EXPR(new OpaqueToken("Ambie
|
||||
* ### Example
|
||||
*
|
||||
* ```typescript
|
||||
* import {AMBIENT_PIPES} from 'angular2/angular2';
|
||||
* import {PLATFORM_PIPES} from 'angular2/angular2';
|
||||
* import {OtherPipe} from './myPipe';
|
||||
*
|
||||
* @Component({
|
||||
@ -47,7 +47,7 @@ export const AMBIENT_DIRECTIVES: OpaqueToken = CONST_EXPR(new OpaqueToken("Ambie
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* bootstrap(MyComponent, [provide(AMBIENT_PIPES, {useValue: [OtherPipe], multi:true})]);
|
||||
* bootstrap(MyComponent, [provide(PLATFORM_PIPES, {useValue: [OtherPipe], multi:true})]);
|
||||
* ```
|
||||
*/
|
||||
export const AMBIENT_PIPES: OpaqueToken = CONST_EXPR(new OpaqueToken("Ambient Pipes"));
|
||||
export const PLATFORM_PIPES: OpaqueToken = CONST_EXPR(new OpaqueToken("Platform Pipes"));
|
@ -61,7 +61,7 @@ import {
|
||||
ClientMessageBrokerFactory,
|
||||
ClientMessageBrokerFactory_
|
||||
} from 'angular2/src/web_workers/shared/client_message_broker';
|
||||
import {AMBIENT_DIRECTIVES, AMBIENT_PIPES} from "angular2/src/core/ambient";
|
||||
import {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from "angular2/src/core/platform_directives_and_pipes";
|
||||
import {COMMON_DIRECTIVES, COMMON_PIPES} from "angular2/common";
|
||||
|
||||
var _rootInjector: Injector;
|
||||
@ -95,8 +95,8 @@ function _injectorProviders(): any[] {
|
||||
AppViewListener,
|
||||
ProtoViewFactory,
|
||||
ViewResolver,
|
||||
provide(AMBIENT_PIPES, {useValue: COMMON_PIPES, multi: true}),
|
||||
provide(AMBIENT_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
|
||||
provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
|
||||
provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
|
||||
DirectiveResolver,
|
||||
Parser,
|
||||
Lexer,
|
||||
|
@ -37,7 +37,7 @@ import {
|
||||
import {TEST_PROVIDERS} from './test_bindings';
|
||||
import {MODULE_SUFFIX} from 'angular2/src/compiler/util';
|
||||
import {IS_DART} from 'angular2/src/facade/lang';
|
||||
import {AMBIENT_DIRECTIVES} from 'angular2/src/core/ambient';
|
||||
import {PLATFORM_DIRECTIVES} from 'angular2/src/core/platform_directives_and_pipes';
|
||||
|
||||
export function main() {
|
||||
describe('RuntimeMetadataResolver', () => {
|
||||
@ -85,10 +85,10 @@ export function main() {
|
||||
.toEqual([resolver.getMetadata(DirectiveWithoutModuleId)]);
|
||||
}));
|
||||
|
||||
describe("ambient directives", () => {
|
||||
beforeEachProviders(() => [provide(AMBIENT_DIRECTIVES, {useValue: [ADirective]})]);
|
||||
describe("platform directives", () => {
|
||||
beforeEachProviders(() => [provide(PLATFORM_DIRECTIVES, {useValue: [ADirective]})]);
|
||||
|
||||
it('should include ambient directives when available',
|
||||
it('should include platform directives when available',
|
||||
inject([RuntimeMetadataResolver], (resolver: RuntimeMetadataResolver) => {
|
||||
expect(resolver.getViewDirectivesMetadata(ComponentWithEverything))
|
||||
.toEqual([
|
||||
|
@ -147,7 +147,7 @@ var NG_ALL = [
|
||||
'By',
|
||||
'CORE_DIRECTIVES',
|
||||
'COMMON_DIRECTIVES',
|
||||
'AMBIENT_DIRECTIVES:js',
|
||||
'PLATFORM_DIRECTIVES:js',
|
||||
'ChangeDetectionError',
|
||||
'ChangeDetectionError.context',
|
||||
'ChangeDetectionError.location',
|
||||
@ -399,7 +399,7 @@ var NG_ALL = [
|
||||
'CyclicDependencyError.message=',
|
||||
'CyclicDependencyError.stackTrace',
|
||||
'COMMON_PIPES',
|
||||
'AMBIENT_PIPES:js',
|
||||
'PLATFORM_PIPES:js',
|
||||
'DOCUMENT',
|
||||
'DatePipe',
|
||||
'DatePipe.supports()',
|
||||
|
Reference in New Issue
Block a user