fix(RouteRegistry): initialize RouteParams.params
Fix a bug caused by RouteRegistry.generate not initializing RouteParams.params to a StringMap Closes #3755
This commit is contained in:
parent
ecf6ba3974
commit
3791c4a682
@ -211,7 +211,7 @@ export class RouteRegistry {
|
|||||||
} else if (segment == '' || segment == '.' || segment == '..') {
|
} else if (segment == '' || segment == '.' || segment == '..') {
|
||||||
throw new BaseException(`"${segment}/" is only allowed at the beginning of a link DSL.`);
|
throw new BaseException(`"${segment}/" is only allowed at the beginning of a link DSL.`);
|
||||||
}
|
}
|
||||||
let params = null;
|
let params = {};
|
||||||
if (i + 1 < linkParams.length) {
|
if (i + 1 < linkParams.length) {
|
||||||
let nextSegment = linkParams[i + 1];
|
let nextSegment = linkParams[i + 1];
|
||||||
if (isStringMap(nextSegment)) {
|
if (isStringMap(nextSegment)) {
|
||||||
|
@ -79,6 +79,13 @@ export function main() {
|
|||||||
expect(url).toEqual('first/one/second/two');
|
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',
|
it('should generate URLs of loaded components after they are loaded',
|
||||||
inject([AsyncTestCompleter], (async) => {
|
inject([AsyncTestCompleter], (async) => {
|
||||||
registry.config(
|
registry.config(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user