Skip to content

Commit 0df878c

Browse files
committed
fix: Avoid crashes when callbacks aren't defined
1 parent 83b267d commit 0df878c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/router-service.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ export class RouterService {
108108
public constructor(
109109
{ routes }: NSVueRouterOptions,
110110
{
111-
routeToCallback,
112-
routeBackCallback,
111+
routeToCallback = null,
112+
routeBackCallback = null,
113113
routeBackFallbackPath = "",
114114
logger = null,
115115
frame = null,
@@ -458,11 +458,17 @@ export class RouterService {
458458
}
459459

460460
if (isNavigatingBack) {
461-
this.routeBackCallback(newRoute, routeOptions);
461+
// Ensure that callback is specified
462+
if (this.routeBackCallback) {
463+
this.routeBackCallback(newRoute, routeOptions);
464+
}
462465

463466
this.vm.$navigateBack(routeOptions);
464467
} else {
465-
this.routeToCallback(newRoute, routeOptions);
468+
// Ensure that callback is specified
469+
if (this.routeToCallback) {
470+
this.routeToCallback(newRoute, routeOptions);
471+
}
466472

467473
this.vm.$navigateTo(newRoute.component, routeOptions);
468474
}

0 commit comments

Comments
 (0)