Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,21 @@ function validateRouteConfig(config: RouteConfig, routes: Array<Object>): void {
}

function evaluateNavigationStrategy(instruction: NavigationInstruction, evaluator: Function, context: any): Promise<NavigationInstruction> {
return Promise.resolve(evaluator.call(context, instruction)).then(() => {
return Promise.resolve(evaluator.call(context, instruction)).then((modules?: string | {[viewportname: string]: moduleId}) => {
if (!('viewPorts' in instruction.config)) {
instruction.config.viewPorts = {
'default': {
moduleId: instruction.config.moduleId
}
};
instruction.config.viewPorts = {};
}

if (typeof modules === 'string') {
modules = {'default': modules};
} else if (modules === undefined) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, if someone has logic in their nav strat that falls back to a null value, they might expect it to run with the default config, but instead, modules will remain null and this will throw an unhandled error.

I'd recommend updating this to check for a falsey value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Roustalski Can you update to handle this case?

modules = {'default': instruction.config.moduleId};
}

for (let key in modules) {
let vp = instruction.config.viewPorts[key] || {};
vp.moduleId = modules[key];
instruction.config.viewPorts[key] = vp;
}

return instruction;
Expand Down