refactor(router): Remove deprecated 'as' from ‘RouteConfig’

BREAKING CHANGE
Remove deprecated 'as' from ‘RouteConfig’ in favour of ‘name’
This commit is contained in:
Vamsi Varikuti 2016-03-19 20:08:25 +05:30 committed by Misko Hevery
parent cbeeff2bd6
commit 49fb7ef421
4 changed files with 3 additions and 51 deletions

View File

@ -11,7 +11,7 @@ import {Instruction} from '../instruction';
* ```
* @RouteConfig([
* { path: '/user', component: UserCmp, as: 'User' }
* { path: '/user', component: UserCmp, name: 'User' }
* ]);
* class MyComp {}
* ```

View File

@ -32,12 +32,7 @@ export function normalizeRouteConfig(config: RouteDefinition,
throw new BaseException(
`Route config should contain exactly one "component", "loader", or "redirectTo" property.`);
}
if (config.as && config.name) {
throw new BaseException(`Route config should contain exactly one "as" or "name" property.`);
}
if (config.as) {
config.name = config.as;
}
if (config.loader) {
var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
return new AsyncRoute({

View File

@ -7,7 +7,7 @@ import {RegexSerializer} from './rules/route_paths/regex_route_path';
* Supported keys:
* - `path` or `aux` (requires exactly one of these)
* - `component`, `loader`, `redirectTo` (requires exactly one of these)
* - `name` or `as` (optional) (requires exactly one of these)
* - `name` (optional)
* - `data` (optional)
*
* See also {@link Route}, {@link AsyncRoute}, {@link AuxRoute}, and {@link Redirect}.
@ -21,7 +21,6 @@ export interface RouteDefinition {
component?: Type | ComponentDefinition;
loader?: () => Promise<Type>;
redirectTo?: any[];
as?: string;
name?: string;
data?: any;
useAsDefault?: boolean;

View File

@ -177,30 +177,6 @@ export function main() {
return null;
})}));
it('should throw if a config has an invalid alias name with "as"',
inject(
[AsyncTestCompleter],
(async) => {
bootstrap(BadAliasCmp, testBindings)
.catch((e) => {
expect(e.originalException)
.toContainError(
`Route "/child" with name "child" does not begin with an uppercase letter. Route names should be PascalCase like "Child".`);
async.done();
return null;
})}));
it('should throw if a config has multiple alias properties "as" and "name"',
inject([AsyncTestCompleter],
(async) => {
bootstrap(MultipleAliasCmp, testBindings)
.catch((e) => {
expect(e.originalException)
.toContainError(
`Route config should contain exactly one "as" or "name" property.`);
async.done();
return null;
})}));
});
}
@ -309,24 +285,6 @@ class WrongConfigCmp {
class BadAliasNameCmp {
}
@Component({
selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/child', component: HelloCmp, as: 'child'}])
class BadAliasCmp {
}
@Component({
selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,
directives: ROUTER_DIRECTIVES
})
@RouteConfig([{path: '/child', component: HelloCmp, as: 'Child', name: 'Child'}])
class MultipleAliasCmp {
}
@Component({
selector: 'app-cmp',
template: `root { <router-outlet></router-outlet> }`,