From 3791c4a6827812c983d2cc6af696abaa765cc479 Mon Sep 17 00:00:00 2001 From: Isaac Park Date: Tue, 25 Aug 2015 11:59:57 -0400 Subject: [PATCH] fix(RouteRegistry): initialize RouteParams.params Fix a bug caused by RouteRegistry.generate not initializing RouteParams.params to a StringMap Closes #3755 --- modules/angular2/src/router/route_registry.ts | 2 +- modules/angular2/test/router/route_registry_spec.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/router/route_registry.ts b/modules/angular2/src/router/route_registry.ts index a08e11c94d..43aecb1391 100644 --- a/modules/angular2/src/router/route_registry.ts +++ b/modules/angular2/src/router/route_registry.ts @@ -211,7 +211,7 @@ export class RouteRegistry { } else if (segment == '' || segment == '.' || segment == '..') { throw new BaseException(`"${segment}/" is only allowed at the beginning of a link DSL.`); } - let params = null; + let params = {}; if (i + 1 < linkParams.length) { let nextSegment = linkParams[i + 1]; if (isStringMap(nextSegment)) { diff --git a/modules/angular2/test/router/route_registry_spec.ts b/modules/angular2/test/router/route_registry_spec.ts index 9e0136e693..04ee4a3b26 100644 --- a/modules/angular2/test/router/route_registry_spec.ts +++ b/modules/angular2/test/router/route_registry_spec.ts @@ -79,6 +79,13 @@ export function main() { expect(url).toEqual('first/one/second/two'); }); + it('should geneate params as an empty StringMap when no params are given', () => { + registry.config(RootHostCmp, + new Route({path: '/test/...', component: DummyParentParamCmp, as: 'test'})); + var instruction = registry.generate(['test'], RootHostCmp); + expect(instruction.component.params).toEqual({}); + }); + it('should generate URLs of loaded components after they are loaded', inject([AsyncTestCompleter], (async) => { registry.config(