Skip to content

Commit ccfadb9

Browse files
committed
refactor: make bindings/directives names consistent
BREAKING CHANGE - `routerDirectives` => `ROUTER_DIRECTIVES` - `routerInjectables` => `ROUTER_BINDINGS` - `ELEMENT_PROBE_CONFIG` => `ELEMENT_PROBE_BINDINGS`
1 parent 8dc509f commit ccfadb9

File tree

8 files changed

+50
-42
lines changed

8 files changed

+50
-42
lines changed

modules/angular2/debug.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export * from './src/debug/debug_element';
2-
export {inspectNativeElement, ELEMENT_PROBE_CONFIG} from './src/debug/debug_element_view_listener';
2+
export {
3+
inspectNativeElement,
4+
ELEMENT_PROBE_BINDINGS
5+
} from './src/debug/debug_element_view_listener';

modules/angular2/router.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,25 @@ import {RouteRegistry} from './src/router/route_registry';
3232
import {Pipeline} from './src/router/pipeline';
3333
import {Location} from './src/router/location';
3434
import {APP_COMPONENT} from './src/core/application_tokens';
35-
import {bind} from './di';
35+
import {Binding} from './di';
3636
import {CONST_EXPR} from './src/facade/lang';
3737
import {List} from './src/facade/collection';
3838

39-
export const routerDirectives: List<any> = CONST_EXPR([RouterOutlet, RouterLink]);
39+
export const ROUTER_DIRECTIVES: List<any> = CONST_EXPR([RouterOutlet, RouterLink]);
4040

41-
export var routerInjectables: List<any> = [
41+
export const ROUTER_BINDINGS: List<any> = CONST_EXPR([
4242
RouteRegistry,
4343
Pipeline,
44-
bind(LocationStrategy).toClass(HTML5LocationStrategy),
44+
CONST_EXPR(new Binding(LocationStrategy, {toClass: HTML5LocationStrategy})),
4545
Location,
46-
bind(Router)
47-
.toFactory((registry, pipeline, location,
48-
appRoot) => { return new RootRouter(registry, pipeline, location, appRoot);},
49-
[RouteRegistry, Pipeline, Location, APP_COMPONENT])
50-
];
46+
CONST_EXPR(
47+
new Binding(Router,
48+
{
49+
toFactory: routerFactory,
50+
deps: CONST_EXPR([RouteRegistry, Pipeline, Location, APP_COMPONENT])
51+
}))
52+
]);
53+
54+
function routerFactory(registry, pipeline, location, appRoot) {
55+
return new RootRouter(registry, pipeline, location, appRoot);
56+
}

modules/angular2/src/debug/debug_element_view_listener.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class DebugElementViewListener implements AppViewListener {
6868
}
6969
}
7070

71-
export var ELEMENT_PROBE_CONFIG = [
71+
export const ELEMENT_PROBE_BINDINGS = CONST_EXPR([
7272
DebugElementViewListener,
73-
bind(AppViewListener).toAlias(DebugElementViewListener),
74-
];
73+
CONST_EXPR(new Binding(AppViewListener, {toAlias: DebugElementViewListener})),
74+
]);

modules/angular2/src/test_lib/test_injector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import {FunctionWrapper, Type} from 'angular2/src/facade/lang';
4848
import {AppViewPool, APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool';
4949
import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
5050
import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils';
51-
import {ELEMENT_PROBE_CONFIG} from 'angular2/debug';
51+
import {ELEMENT_PROBE_BINDINGS} from 'angular2/debug';
5252
import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
5353
import {RenderCompiler, Renderer} from 'angular2/src/render/api';
5454
import {
@@ -117,7 +117,7 @@ function _getAppBindings() {
117117
AppViewManager,
118118
AppViewManagerUtils,
119119
Serializer,
120-
ELEMENT_PROBE_CONFIG,
120+
ELEMENT_PROBE_BINDINGS,
121121
bind(APP_VIEW_POOL_CAPACITY).toValue(500),
122122
Compiler,
123123
CompilerCache,

modules/angular2/test/router/route_config_spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import {DOCUMENT} from 'angular2/src/render/render';
1919
import {Type} from 'angular2/src/facade/lang';
2020

2121
import {
22-
routerInjectables,
22+
ROUTER_BINDINGS,
2323
Router,
2424
RouteConfig,
2525
APP_BASE_HREF,
26-
routerDirectives
26+
ROUTER_DIRECTIVES
2727
} from 'angular2/router';
2828

2929
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
@@ -47,7 +47,7 @@ export function main() {
4747
var logger = new _ArrayLogger();
4848
var exceptionHandler = new ExceptionHandler(logger, true);
4949
testBindings = [
50-
routerInjectables,
50+
ROUTER_BINDINGS,
5151
bind(LocationStrategy).toClass(MockLocationStrategy),
5252
bind(DOCUMENT).toValue(fakeDoc),
5353
bind(ExceptionHandler).toValue(exceptionHandler)
@@ -145,7 +145,7 @@ class HelloCmp {
145145
}
146146

147147
@Component({selector: 'app-cmp'})
148-
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
148+
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
149149
@RouteConfig([{path: '/before', redirectTo: '/after'}, {path: '/after', component: HelloCmp}])
150150
class RedirectAppCmp {
151151
constructor(public router: Router, public location: LocationStrategy) {}
@@ -156,7 +156,7 @@ function HelloLoader(): Promise<any> {
156156
}
157157

158158
@Component({selector: 'app-cmp'})
159-
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
159+
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
160160
@RouteConfig([
161161
{path: '/hello', component: {type: 'loader', loader: HelloLoader}},
162162
])
@@ -165,7 +165,7 @@ class AsyncAppCmp {
165165
}
166166

167167
@Component({selector: 'app-cmp'})
168-
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
168+
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
169169
@RouteConfig([
170170
{path: '/hello', component: {type: 'constructor', constructor: HelloCmp}},
171171
])
@@ -174,26 +174,26 @@ class ExplicitConstructorAppCmp {
174174
}
175175

176176
@Component({selector: 'parent-cmp'})
177-
@View({template: `parent { <router-outlet></router-outlet> }`, directives: routerDirectives})
177+
@View({template: `parent { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
178178
@RouteConfig([{path: '/child', component: HelloCmp}])
179179
class ParentCmp {
180180
}
181181

182182
@Component({selector: 'app-cmp'})
183-
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
183+
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
184184
@RouteConfig([{path: '/parent/...', component: ParentCmp}])
185185
class HierarchyAppCmp {
186186
constructor(public router: Router, public location: LocationStrategy) {}
187187
}
188188

189189
@Component({selector: 'app-cmp'})
190-
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
190+
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
191191
@RouteConfig([{path: '/hello'}])
192192
class WrongConfigCmp {
193193
}
194194

195195
@Component({selector: 'app-cmp'})
196-
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
196+
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
197197
@RouteConfig([
198198
{path: '/hello', component: {type: 'intentionallyWrongComponentType', constructor: HelloCmp}},
199199
])

modules/angular2/test/router/router_integration_spec.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import {RouteConfig, Route, Redirect} from 'angular2/src/router/route_config_dec
2323
import {PromiseWrapper} from 'angular2/src/facade/async';
2424
import {BaseException} from 'angular2/src/facade/lang';
2525
import {
26-
routerInjectables,
26+
ROUTER_BINDINGS,
2727
RouteParams,
2828
Router,
2929
APP_BASE_HREF,
30-
routerDirectives,
30+
ROUTER_DIRECTIVES,
3131
HashLocationStrategy
3232
} from 'angular2/router';
3333

@@ -37,9 +37,8 @@ import {APP_COMPONENT} from 'angular2/src/core/application_tokens';
3737

3838
export function main() {
3939
describe('router injectables', () => {
40-
beforeEachBindings(() => {
41-
return [routerInjectables, bind(LocationStrategy).toClass(MockLocationStrategy)];
42-
});
40+
beforeEachBindings(
41+
() => { return [ROUTER_BINDINGS, bind(LocationStrategy).toClass(MockLocationStrategy)]; });
4342

4443
// do not refactor out the `bootstrap` functionality. We still want to
4544
// keep this test around so we can ensure that bootstrapping a router works
@@ -51,7 +50,7 @@ export function main() {
5150

5251
bootstrap(AppCmp,
5352
[
54-
routerInjectables,
53+
ROUTER_BINDINGS,
5554
bind(LocationStrategy).toClass(MockLocationStrategy),
5655
bind(DOCUMENT).toValue(fakeDoc)
5756
])
@@ -210,26 +209,26 @@ class Hello2Cmp {
210209
}
211210

212211
@Component({selector: 'app-cmp'})
213-
@View({template: "outer { <router-outlet></router-outlet> }", directives: routerDirectives})
212+
@View({template: "outer { <router-outlet></router-outlet> }", directives: ROUTER_DIRECTIVES})
214213
@RouteConfig([new Route({path: '/', component: HelloCmp})])
215214
class AppCmp {
216215
constructor(public router: Router, public location: LocationStrategy) {}
217216
}
218217

219218
@Component({selector: 'parent-cmp'})
220-
@View({template: `parent { <router-outlet></router-outlet> }`, directives: routerDirectives})
219+
@View({template: `parent { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
221220
@RouteConfig([new Route({path: '/child', component: HelloCmp})])
222221
class ParentCmp {
223222
}
224223

225224
@Component({selector: 'super-parent-cmp'})
226-
@View({template: `super-parent { <router-outlet></router-outlet> }`, directives: routerDirectives})
225+
@View({template: `super-parent { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
227226
@RouteConfig([new Route({path: '/child', component: Hello2Cmp})])
228227
class SuperParentCmp {
229228
}
230229

231230
@Component({selector: 'app-cmp'})
232-
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
231+
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
233232
@RouteConfig([
234233
new Route({path: '/parent/...', component: ParentCmp}),
235234
new Route({path: '/super-parent/...', component: SuperParentCmp})
@@ -246,7 +245,7 @@ class QSCmp {
246245
}
247246

248247
@Component({selector: 'app-cmp'})
249-
@View({template: `<router-outlet></router-outlet>`, directives: routerDirectives})
248+
@View({template: `<router-outlet></router-outlet>`, directives: ROUTER_DIRECTIVES})
250249
@RouteConfig([new Route({path: '/qs', component: QSCmp})])
251250
class QueryStringAppCmp {
252251
constructor(public router: Router, public location: LocationStrategy) {}
@@ -259,7 +258,7 @@ class BrokenCmp {
259258
}
260259

261260
@Component({selector: 'app-cmp'})
262-
@View({template: `outer { <router-outlet></router-outlet> }`, directives: routerDirectives})
261+
@View({template: `outer { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
263262
@RouteConfig([new Route({path: '/cause-error', component: BrokenCmp})])
264263
class BrokenAppCmp {
265264
constructor(public router: Router, public location: LocationStrategy) {}

modules/examples/src/routing/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {InboxApp} from './inbox-app';
22
import {bind} from 'angular2/angular2';
33
import {bootstrap} from 'angular2/bootstrap';
4-
import {routerInjectables, HashLocationStrategy, LocationStrategy} from 'angular2/router';
4+
import {ROUTER_BINDINGS, HashLocationStrategy, LocationStrategy} from 'angular2/router';
55

66
import {reflector} from 'angular2/src/reflection/reflection';
77
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
88

99
export function main() {
1010
reflector.reflectionCapabilities = new ReflectionCapabilities();
11-
bootstrap(InboxApp, [routerInjectables, bind(LocationStrategy).toClass(HashLocationStrategy)]);
11+
bootstrap(InboxApp, [ROUTER_BINDINGS, bind(LocationStrategy).toClass(HashLocationStrategy)]);
1212
}

typing_spec/router_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
///<reference path="../dist/docs/typings/angular2/router.d.ts"/>
33

44
import {Component, bootstrap, View} from 'angular2/angular2';
5-
import {RouteConfig, routerDirectives, routerInjectables} from 'angular2/router';
5+
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_BINDINGS} from 'angular2/router';
66

77
@Component({
88
selector: 'my-app'
@@ -19,7 +19,7 @@ class FooCmp {
1919
})
2020
@View({
2121
template: '<h1>Hello {{ name }}</h1><router-outlet></router-outlet>',
22-
directives: routerDirectives
22+
directives: ROUTER_DIRECTIVES
2323
})
2424
@RouteConfig([
2525
{path: '/home', component: FooCmp}
@@ -30,4 +30,4 @@ class MyAppComponent {
3030
constructor() { this.name = 'Alice'; }
3131
}
3232

33-
bootstrap(MyAppComponent, routerInjectables);
33+
bootstrap(MyAppComponent, ROUTER_BINDINGS);

0 commit comments

Comments
 (0)