X Tutup
Skip to content

Commit e27665c

Browse files
committed
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
1 parent 2618bec commit e27665c

File tree

16 files changed

+72
-72
lines changed

16 files changed

+72
-72
lines changed

modules/angular2/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ export * from './src/common/directives';
1919
export * from './src/common/forms';
2020
export * from './src/core/debug';
2121
export * from './src/core/change_detection';
22-
export * from './src/core/ambient';
22+
export * from './src/core/platform_directives_and_pipes';
2323
export * from './src/core/dev_mode';

modules/angular2/src/compiler/compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export {
66
CompileTemplateMetadata
77
} from './directive_metadata';
88
export {SourceModule, SourceWithImports} from './source_module';
9-
export {AMBIENT_DIRECTIVES, AMBIENT_PIPES} from 'angular2/src/core/ambient';
9+
export {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/src/core/platform_directives_and_pipes';
1010

1111
import {assertionsEnabled, Type} from 'angular2/src/facade/lang';
1212
import {provide, Provider} from 'angular2/src/core/di';

modules/angular2/src/compiler/runtime_metadata.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ import {hasLifecycleHook} from 'angular2/src/core/linker/directive_lifecycle_ref
1818
import {LifecycleHooks, LIFECYCLE_HOOKS_VALUES} from 'angular2/src/core/linker/interfaces';
1919
import {reflector} from 'angular2/src/core/reflection/reflection';
2020
import {Injectable, Inject, Optional} from 'angular2/src/core/di';
21-
import {AMBIENT_DIRECTIVES} from 'angular2/src/core/ambient';
21+
import {PLATFORM_DIRECTIVES} from 'angular2/src/core/platform_directives_and_pipes';
2222
import {MODULE_SUFFIX} from './util';
2323

2424
@Injectable()
2525
export class RuntimeMetadataResolver {
2626
private _cache = new Map<Type, cpl.CompileDirectiveMetadata>();
2727

2828
constructor(private _directiveResolver: DirectiveResolver, private _viewResolver: ViewResolver,
29-
@Optional() @Inject(AMBIENT_DIRECTIVES) private _ambientDirectives: Type[]) {}
29+
@Optional() @Inject(PLATFORM_DIRECTIVES) private _platformDirectives: Type[]) {}
3030

3131
getMetadata(directiveType: Type): cpl.CompileDirectiveMetadata {
3232
var meta = this._cache.get(directiveType);
@@ -69,7 +69,7 @@ export class RuntimeMetadataResolver {
6969

7070
getViewDirectivesMetadata(component: Type): cpl.CompileDirectiveMetadata[] {
7171
var view = this._viewResolver.resolve(component);
72-
var directives = flattenDirectives(view, this._ambientDirectives);
72+
var directives = flattenDirectives(view, this._platformDirectives);
7373
for (var i = 0; i < directives.length; i++) {
7474
if (!isValidDirective(directives[i])) {
7575
throw new BaseException(
@@ -87,10 +87,10 @@ function removeDuplicates(items: any[]): any[] {
8787
return MapWrapper.keys(m);
8888
}
8989

90-
function flattenDirectives(view: ViewMetadata, ambientDirectives: any[]): Type[] {
90+
function flattenDirectives(view: ViewMetadata, platformDirectives: any[]): Type[] {
9191
let directives = [];
92-
if (isPresent(ambientDirectives)) {
93-
flattenArray(ambientDirectives, directives);
92+
if (isPresent(platformDirectives)) {
93+
flattenArray(platformDirectives, directives);
9494
}
9595
if (isPresent(view.directives)) {
9696
flattenArray(view.directives, directives);

modules/angular2/src/core/application_ref.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {AppViewManager_} from "./linker/view_manager";
4747
import {Compiler_} from "./linker/compiler";
4848
import {wtfLeave, wtfCreateScope, WtfScopeFn} from './profile/profile';
4949
import {ChangeDetectorRef} from 'angular2/src/core/change_detection/change_detector_ref';
50-
import {AMBIENT_DIRECTIVES, AMBIENT_PIPES} from "angular2/src/core/ambient";
50+
import {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from "angular2/src/core/platform_directives_and_pipes";
5151
import {lockDevMode} from 'angular2/src/facade/lang';
5252
import {COMMON_DIRECTIVES, COMMON_PIPES} from "angular2/common";
5353

@@ -110,8 +110,8 @@ export function applicationCommonProviders(): Array<Type | Provider | any[]> {
110110
provide(KeyValueDiffers, {useValue: defaultKeyValueDiffers}),
111111
DirectiveResolver,
112112
PipeResolver,
113-
provide(AMBIENT_PIPES, {useValue: COMMON_PIPES, multi: true}),
114-
provide(AMBIENT_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
113+
provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
114+
provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
115115
provide(DynamicComponentLoader, {useClass: DynamicComponentLoader_})
116116
];
117117
}

modules/angular2/src/core/linker/proto_view_factory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {DirectiveResolver} from './directive_resolver';
1414
import {ViewResolver} from './view_resolver';
1515
import {PipeResolver} from './pipe_resolver';
1616
import {ViewMetadata, ViewEncapsulation} from '../metadata/view';
17-
import {AMBIENT_PIPES} from 'angular2/src/core/ambient';
17+
import {PLATFORM_PIPES} from 'angular2/src/core/platform_directives_and_pipes';
1818

1919
import {
2020
visitAllCommands,
@@ -40,7 +40,7 @@ export class ProtoViewFactory {
4040
private _nextTemplateId: number = 0;
4141

4242
constructor(private _renderer: Renderer,
43-
@Optional() @Inject(AMBIENT_PIPES) private _ambientPipes: Array<Type | any[]>,
43+
@Optional() @Inject(PLATFORM_PIPES) private _platformPipes: Array<Type | any[]>,
4444
private _directiveResolver: DirectiveResolver, private _viewResolver: ViewResolver,
4545
private _pipeResolver: PipeResolver, @Inject(APP_ID) private _appId: string) {}
4646

@@ -119,8 +119,8 @@ export class ProtoViewFactory {
119119

120120
private _flattenPipes(view: ViewMetadata): any[] {
121121
let pipes = [];
122-
if (isPresent(this._ambientPipes)) {
123-
_flattenArray(this._ambientPipes, pipes);
122+
if (isPresent(this._platformPipes)) {
123+
_flattenArray(this._platformPipes, pipes);
124124
}
125125
if (isPresent(view.pipes)) {
126126
_flattenArray(view.pipes, pipes);

modules/angular2/src/core/ambient.ts renamed to modules/angular2/src/core/platform_directives_and_pipes.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {CONST_EXPR} from "angular2/src/facade/lang";
88
* ### Example
99
*
1010
* ```typescript
11-
* import {AMBIENT_DIRECTIVES} from 'angular2/angular2';
11+
* import {PLATFORM_DIRECTIVES} from 'angular2/angular2';
1212
* import {OtherDirective} from './myDirectives';
1313
*
1414
* @Component({
@@ -22,10 +22,10 @@ import {CONST_EXPR} from "angular2/src/facade/lang";
2222
* ...
2323
* }
2424
*
25-
* bootstrap(MyComponent, [provide(AMBIENT_DIRECTIVES, {useValue: [OtherDirective], multi:true})]);
25+
* bootstrap(MyComponent, [provide(PLATFORM_DIRECTIVES, {useValue: [OtherDirective], multi:true})]);
2626
* ```
2727
*/
28-
export const AMBIENT_DIRECTIVES: OpaqueToken = CONST_EXPR(new OpaqueToken("Ambient Directives"));
28+
export const PLATFORM_DIRECTIVES: OpaqueToken = CONST_EXPR(new OpaqueToken("Platform Directives"));
2929

3030
/**
3131
* 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
3434
* ### Example
3535
*
3636
* ```typescript
37-
* import {AMBIENT_PIPES} from 'angular2/angular2';
37+
* import {PLATFORM_PIPES} from 'angular2/angular2';
3838
* import {OtherPipe} from './myPipe';
3939
*
4040
* @Component({
@@ -47,7 +47,7 @@ export const AMBIENT_DIRECTIVES: OpaqueToken = CONST_EXPR(new OpaqueToken("Ambie
4747
* ...
4848
* }
4949
*
50-
* bootstrap(MyComponent, [provide(AMBIENT_PIPES, {useValue: [OtherPipe], multi:true})]);
50+
* bootstrap(MyComponent, [provide(PLATFORM_PIPES, {useValue: [OtherPipe], multi:true})]);
5151
* ```
5252
*/
53-
export const AMBIENT_PIPES: OpaqueToken = CONST_EXPR(new OpaqueToken("Ambient Pipes"));
53+
export const PLATFORM_PIPES: OpaqueToken = CONST_EXPR(new OpaqueToken("Platform Pipes"));

modules/angular2/src/web_workers/ui/di_bindings.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import {
6161
ClientMessageBrokerFactory,
6262
ClientMessageBrokerFactory_
6363
} from 'angular2/src/web_workers/shared/client_message_broker';
64-
import {AMBIENT_DIRECTIVES, AMBIENT_PIPES} from "angular2/src/core/ambient";
64+
import {PLATFORM_DIRECTIVES, PLATFORM_PIPES} from "angular2/src/core/platform_directives_and_pipes";
6565
import {COMMON_DIRECTIVES, COMMON_PIPES} from "angular2/common";
6666

6767
var _rootInjector: Injector;
@@ -95,8 +95,8 @@ function _injectorProviders(): any[] {
9595
AppViewListener,
9696
ProtoViewFactory,
9797
ViewResolver,
98-
provide(AMBIENT_PIPES, {useValue: COMMON_PIPES, multi: true}),
99-
provide(AMBIENT_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
98+
provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
99+
provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
100100
DirectiveResolver,
101101
Parser,
102102
Lexer,

modules/angular2/test/compiler/runtime_metadata_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
import {TEST_PROVIDERS} from './test_bindings';
3838
import {MODULE_SUFFIX} from 'angular2/src/compiler/util';
3939
import {IS_DART} from 'angular2/src/facade/lang';
40-
import {AMBIENT_DIRECTIVES} from 'angular2/src/core/ambient';
40+
import {PLATFORM_DIRECTIVES} from 'angular2/src/core/platform_directives_and_pipes';
4141

4242
export function main() {
4343
describe('RuntimeMetadataResolver', () => {
@@ -85,10 +85,10 @@ export function main() {
8585
.toEqual([resolver.getMetadata(DirectiveWithoutModuleId)]);
8686
}));
8787

88-
describe("ambient directives", () => {
89-
beforeEachProviders(() => [provide(AMBIENT_DIRECTIVES, {useValue: [ADirective]})]);
88+
describe("platform directives", () => {
89+
beforeEachProviders(() => [provide(PLATFORM_DIRECTIVES, {useValue: [ADirective]})]);
9090

91-
it('should include ambient directives when available',
91+
it('should include platform directives when available',
9292
inject([RuntimeMetadataResolver], (resolver: RuntimeMetadataResolver) => {
9393
expect(resolver.getViewDirectivesMetadata(ComponentWithEverything))
9494
.toEqual([

modules/angular2/test/public_api_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ var NG_ALL = [
147147
'By',
148148
'CORE_DIRECTIVES',
149149
'COMMON_DIRECTIVES',
150-
'AMBIENT_DIRECTIVES:js',
150+
'PLATFORM_DIRECTIVES:js',
151151
'ChangeDetectionError',
152152
'ChangeDetectionError.context',
153153
'ChangeDetectionError.location',
@@ -399,7 +399,7 @@ var NG_ALL = [
399399
'CyclicDependencyError.message=',
400400
'CyclicDependencyError.stackTrace',
401401
'COMMON_PIPES',
402-
'AMBIENT_PIPES:js',
402+
'PLATFORM_PIPES:js',
403403
'DOCUMENT',
404404
'DatePipe',
405405
'DatePipe.supports()',

modules/playground/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependency_overrides:
1717
path: ../angular2_material
1818
transformers:
1919
- angular2:
20-
ambient_directives: 'package:angular2/src/common/directives.dart#CORE_DIRECTIVES'
20+
platform_directives: 'package:angular2/src/common/directives.dart#CORE_DIRECTIVES'
2121
entry_points:
2222
- web/src/gestures/index.dart
2323
- web/src/hello_world/index.dart

0 commit comments

Comments
 (0)
X Tutup