refactor: make bindings/directives names consistent
BREAKING CHANGE - `routerDirectives` => `ROUTER_DIRECTIVES` - `routerInjectables` => `ROUTER_BINDINGS` - `ELEMENT_PROBE_CONFIG` => `ELEMENT_PROBE_BINDINGS`
This commit is contained in:
parent
8dc509f688
commit
ccfadb9b47
|
@ -1,2 +1,5 @@
|
|||
export * from './src/debug/debug_element';
|
||||
export {inspectNativeElement, ELEMENT_PROBE_CONFIG} from './src/debug/debug_element_view_listener';
|
||||
export {
|
||||
inspectNativeElement,
|
||||
ELEMENT_PROBE_BINDINGS
|
||||
} from './src/debug/debug_element_view_listener';
|
||||
|
|
|
@ -32,19 +32,25 @@ import {RouteRegistry} from './src/router/route_registry';
|
|||
import {Pipeline} from './src/router/pipeline';
|
||||
import {Location} from './src/router/location';
|
||||
import {APP_COMPONENT} from './src/core/application_tokens';
|
||||
import {bind} from './di';
|
||||
import {Binding} from './di';
|
||||
import {CONST_EXPR} from './src/facade/lang';
|
||||
import {List} from './src/facade/collection';
|
||||
|
||||
export const routerDirectives: List<any> = CONST_EXPR([RouterOutlet, RouterLink]);
|
||||
export const ROUTER_DIRECTIVES: List<any> = CONST_EXPR([RouterOutlet, RouterLink]);
|
||||
|
||||
export var routerInjectables: List<any> = [
|
||||
export const ROUTER_BINDINGS: List<any> = CONST_EXPR([
|
||||
RouteRegistry,
|
||||
Pipeline,
|
||||
bind(LocationStrategy).toClass(HTML5LocationStrategy),
|
||||
CONST_EXPR(new Binding(LocationStrategy, {toClass: HTML5LocationStrategy})),
|
||||
Location,
|
||||
bind(Router)
|
||||
.toFactory((registry, pipeline, location,
|
||||
appRoot) => { return new RootRouter(registry, pipeline, location, appRoot);},
|
||||
[RouteRegistry, Pipeline, Location, APP_COMPONENT])
|
||||
];
|
||||
CONST_EXPR(
|
||||
new Binding(Router,
|
||||
{
|
||||
toFactory: routerFactory,
|
||||
deps: CONST_EXPR([RouteRegistry, Pipeline, Location, APP_COMPONENT])
|
||||
}))
|
||||
]);
|
||||
|
||||
function routerFactory(registry, pipeline, location, appRoot) {
|
||||
return new RootRouter(registry, pipeline, location, appRoot);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ export class DebugElementViewListener implements AppViewListener {
|
|||
}
|
||||
}
|
||||
|
||||
export var ELEMENT_PROBE_CONFIG = [
|
||||
export const ELEMENT_PROBE_BINDINGS = CONST_EXPR([
|
||||
DebugElementViewListener,
|
||||
bind(AppViewListener).toAlias(DebugElementViewListener),
|
||||
];
|
||||
CONST_EXPR(new Binding(AppViewListener, {toAlias: DebugElementViewListener})),
|
||||
]);
|
||||
|
|
|
@ -48,7 +48,7 @@ import {FunctionWrapper, Type} from 'angular2/src/facade/lang';
|
|||
import {AppViewPool, APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool';
|
||||
import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
|
||||
import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils';
|
||||
import {ELEMENT_PROBE_CONFIG} from 'angular2/debug';
|
||||
import {ELEMENT_PROBE_BINDINGS} from 'angular2/debug';
|
||||
import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
|
||||
import {RenderCompiler, Renderer} from 'angular2/src/render/api';
|
||||
import {
|
||||
|
@ -117,7 +117,7 @@ function _getAppBindings() {
|
|||
AppViewManager,
|
||||
AppViewManagerUtils,
|
||||
Serializer,
|
||||
ELEMENT_PROBE_CONFIG,
|
||||
ELEMENT_PROBE_BINDINGS,
|
||||
bind(APP_VIEW_POOL_CAPACITY).toValue(500),
|
||||
Compiler,
|
||||
CompilerCache,
|
||||
|
|
|
@ -19,11 +19,11 @@ import {DOCUMENT} from 'angular2/src/render/render';
|
|||
import {Type} from 'angular2/src/facade/lang';
|
||||
|
||||
import {
|
||||
routerInjectables,
|
||||
ROUTER_BINDINGS,
|
||||
Router,
|
||||
RouteConfig,
|
||||
APP_BASE_HREF,
|
||||
routerDirectives
|
||||
ROUTER_DIRECTIVES
|
||||
} from 'angular2/router';
|
||||
|
||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||
|
@ -47,7 +47,7 @@ export function main() {
|
|||
var logger = new _ArrayLogger();
|
||||
var exceptionHandler = new ExceptionHandler(logger, true);
|
||||
testBindings = [
|
||||
routerInjectables,
|
||||
ROUTER_BINDINGS,
|
||||
bind(LocationStrategy).toClass(MockLocationStrategy),
|
||||
bind(DOCUMENT).toValue(fakeDoc),
|
||||
bind(ExceptionHandler).toValue(exceptionHandler)
|
||||
|
@ -145,7 +145,7 @@ class HelloCmp {
|
|||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([{path: '/before', redirectTo: '/after'}, {path: '/after', component: HelloCmp}])
|
||||
class RedirectAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
|
@ -156,7 +156,7 @@ function HelloLoader(): Promise<any> {
|
|||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([
|
||||
{path: '/hello', component: {type: 'loader', loader: HelloLoader}},
|
||||
])
|
||||
|
@ -165,7 +165,7 @@ class AsyncAppCmp {
|
|||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([
|
||||
{path: '/hello', component: {type: 'constructor', constructor: HelloCmp}},
|
||||
])
|
||||
|
@ -174,26 +174,26 @@ class ExplicitConstructorAppCmp {
|
|||
}
|
||||
|
||||
@Component({selector: 'parent-cmp'})
|
||||
@View({template: `parent { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `parent { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([{path: '/child', component: HelloCmp}])
|
||||
class ParentCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([{path: '/parent/...', component: ParentCmp}])
|
||||
class HierarchyAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([{path: '/hello'}])
|
||||
class WrongConfigCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([
|
||||
{path: '/hello', component: {type: 'intentionallyWrongComponentType', constructor: HelloCmp}},
|
||||
])
|
||||
|
|
|
@ -23,11 +23,11 @@ import {RouteConfig, Route, Redirect} from 'angular2/src/router/route_config_dec
|
|||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {BaseException} from 'angular2/src/facade/lang';
|
||||
import {
|
||||
routerInjectables,
|
||||
ROUTER_BINDINGS,
|
||||
RouteParams,
|
||||
Router,
|
||||
APP_BASE_HREF,
|
||||
routerDirectives,
|
||||
ROUTER_DIRECTIVES,
|
||||
HashLocationStrategy
|
||||
} from 'angular2/router';
|
||||
|
||||
|
@ -37,9 +37,8 @@ import {APP_COMPONENT} from 'angular2/src/core/application_tokens';
|
|||
|
||||
export function main() {
|
||||
describe('router injectables', () => {
|
||||
beforeEachBindings(() => {
|
||||
return [routerInjectables, bind(LocationStrategy).toClass(MockLocationStrategy)];
|
||||
});
|
||||
beforeEachBindings(
|
||||
() => { return [ROUTER_BINDINGS, bind(LocationStrategy).toClass(MockLocationStrategy)]; });
|
||||
|
||||
// do not refactor out the `bootstrap` functionality. We still want to
|
||||
// keep this test around so we can ensure that bootstrapping a router works
|
||||
|
@ -51,7 +50,7 @@ export function main() {
|
|||
|
||||
bootstrap(AppCmp,
|
||||
[
|
||||
routerInjectables,
|
||||
ROUTER_BINDINGS,
|
||||
bind(LocationStrategy).toClass(MockLocationStrategy),
|
||||
bind(DOCUMENT).toValue(fakeDoc)
|
||||
])
|
||||
|
@ -210,26 +209,26 @@ class Hello2Cmp {
|
|||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: "outer { <router-outlet></router-outlet> }", directives: routerDirectives})
|
||||
@View({template: "outer { <router-outlet></router-outlet> }", directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([new Route({path: '/', component: HelloCmp})])
|
||||
class AppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
}
|
||||
|
||||
@Component({selector: 'parent-cmp'})
|
||||
@View({template: `parent { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `parent { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([new Route({path: '/child', component: HelloCmp})])
|
||||
class ParentCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'super-parent-cmp'})
|
||||
@View({template: `super-parent { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `super-parent { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([new Route({path: '/child', component: Hello2Cmp})])
|
||||
class SuperParentCmp {
|
||||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `root { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([
|
||||
new Route({path: '/parent/...', component: ParentCmp}),
|
||||
new Route({path: '/super-parent/...', component: SuperParentCmp})
|
||||
|
@ -246,7 +245,7 @@ class QSCmp {
|
|||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `<router-outlet></router-outlet>`, directives: routerDirectives})
|
||||
@View({template: `<router-outlet></router-outlet>`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([new Route({path: '/qs', component: QSCmp})])
|
||||
class QueryStringAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
|
@ -259,7 +258,7 @@ class BrokenCmp {
|
|||
}
|
||||
|
||||
@Component({selector: 'app-cmp'})
|
||||
@View({template: `outer { <router-outlet></router-outlet> }`, directives: routerDirectives})
|
||||
@View({template: `outer { <router-outlet></router-outlet> }`, directives: ROUTER_DIRECTIVES})
|
||||
@RouteConfig([new Route({path: '/cause-error', component: BrokenCmp})])
|
||||
class BrokenAppCmp {
|
||||
constructor(public router: Router, public location: LocationStrategy) {}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import {InboxApp} from './inbox-app';
|
||||
import {bind} from 'angular2/angular2';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {routerInjectables, HashLocationStrategy, LocationStrategy} from 'angular2/router';
|
||||
import {ROUTER_BINDINGS, HashLocationStrategy, LocationStrategy} from 'angular2/router';
|
||||
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
|
||||
|
||||
export function main() {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
bootstrap(InboxApp, [routerInjectables, bind(LocationStrategy).toClass(HashLocationStrategy)]);
|
||||
bootstrap(InboxApp, [ROUTER_BINDINGS, bind(LocationStrategy).toClass(HashLocationStrategy)]);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
///<reference path="../dist/docs/typings/angular2/router.d.ts"/>
|
||||
|
||||
import {Component, bootstrap, View} from 'angular2/angular2';
|
||||
import {RouteConfig, routerDirectives, routerInjectables} from 'angular2/router';
|
||||
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_BINDINGS} from 'angular2/router';
|
||||
|
||||
@Component({
|
||||
selector: 'my-app'
|
||||
|
@ -19,7 +19,7 @@ class FooCmp {
|
|||
})
|
||||
@View({
|
||||
template: '<h1>Hello {{ name }}</h1><router-outlet></router-outlet>',
|
||||
directives: routerDirectives
|
||||
directives: ROUTER_DIRECTIVES
|
||||
})
|
||||
@RouteConfig([
|
||||
{path: '/home', component: FooCmp}
|
||||
|
@ -30,4 +30,4 @@ class MyAppComponent {
|
|||
constructor() { this.name = 'Alice'; }
|
||||
}
|
||||
|
||||
bootstrap(MyAppComponent, routerInjectables);
|
||||
bootstrap(MyAppComponent, ROUTER_BINDINGS);
|
||||
|
|
Loading…
Reference in New Issue