feat: remove MapWrapper.create()/get()/set().
Better dart2js code, better Angular code.
This commit is contained in:
@ -27,12 +27,12 @@ export class RouteRecognizer {
|
||||
matchers: Map<RegExp, PathRecognizer>;
|
||||
|
||||
constructor() {
|
||||
this.names = MapWrapper.create();
|
||||
this.matchers = MapWrapper.create();
|
||||
this.redirects = MapWrapper.create();
|
||||
this.names = new Map();
|
||||
this.matchers = new Map();
|
||||
this.redirects = new Map();
|
||||
}
|
||||
|
||||
addRedirect(path: string, target: string): void { MapWrapper.set(this.redirects, path, target); }
|
||||
addRedirect(path: string, target: string): void { this.redirects.set(path, target); }
|
||||
|
||||
addConfig(path: string, handler: any, alias: string = null): void {
|
||||
var recognizer = new PathRecognizer(path, handler);
|
||||
@ -42,9 +42,9 @@ export class RouteRecognizer {
|
||||
`Configuration '${path}' conflicts with existing route '${matcher.path}'`);
|
||||
}
|
||||
});
|
||||
MapWrapper.set(this.matchers, recognizer.regex, recognizer);
|
||||
this.matchers.set(recognizer.regex, recognizer);
|
||||
if (isPresent(alias)) {
|
||||
MapWrapper.set(this.names, alias, recognizer);
|
||||
this.names.set(alias, recognizer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ export class RouteRecognizer {
|
||||
hasRoute(name: string): boolean { return MapWrapper.contains(this.names, name); }
|
||||
|
||||
generate(name: string, params: any): string {
|
||||
var pathRecognizer = MapWrapper.get(this.names, name);
|
||||
var pathRecognizer = this.names.get(name);
|
||||
return isPresent(pathRecognizer) ? pathRecognizer.generate(params) : null;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import {reflector} from 'angular2/src/reflection/reflection';
|
||||
export class RouteRegistry {
|
||||
_rules: Map<any, RouteRecognizer>;
|
||||
|
||||
constructor() { this._rules = MapWrapper.create(); }
|
||||
constructor() { this._rules = new Map(); }
|
||||
|
||||
/**
|
||||
* Given a component and a configuration object, add the route to this registry
|
||||
@ -37,11 +37,11 @@ export class RouteRegistry {
|
||||
config(parentComponent, config: StringMap<string, any>): void {
|
||||
assertValidConfig(config);
|
||||
|
||||
var recognizer: RouteRecognizer = MapWrapper.get(this._rules, parentComponent);
|
||||
var recognizer: RouteRecognizer = this._rules.get(parentComponent);
|
||||
|
||||
if (isBlank(recognizer)) {
|
||||
recognizer = new RouteRecognizer();
|
||||
MapWrapper.set(this._rules, parentComponent, recognizer);
|
||||
this._rules.set(parentComponent, recognizer);
|
||||
}
|
||||
|
||||
if (StringMapWrapper.contains(config, 'redirectTo')) {
|
||||
@ -90,7 +90,7 @@ export class RouteRegistry {
|
||||
* the application into the state specified by the
|
||||
*/
|
||||
recognize(url: string, parentComponent): Promise<Instruction> {
|
||||
var componentRecognizer = MapWrapper.get(this._rules, parentComponent);
|
||||
var componentRecognizer = this._rules.get(parentComponent);
|
||||
if (isBlank(componentRecognizer)) {
|
||||
return PromiseWrapper.resolve(null);
|
||||
}
|
||||
@ -145,7 +145,7 @@ export class RouteRegistry {
|
||||
|
||||
generate(name: string, params: StringMap<string, string>, hostComponent): string {
|
||||
// TODO: implement for hierarchical routes
|
||||
var componentRecognizer = MapWrapper.get(this._rules, hostComponent);
|
||||
var componentRecognizer = this._rules.get(hostComponent);
|
||||
return isPresent(componentRecognizer) ? componentRecognizer.generate(name, params) : null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user