diff --git a/Actions.js b/Actions.js index 680e811ed..6f32fb6df 100644 --- a/Actions.js +++ b/Actions.js @@ -99,8 +99,12 @@ class Actions { debug("Pop, router="+router.name+" stack length:"+router.stack.length); debug("Current route="+router.currentRoute.name+" type="+router.currentRoute.type); while (router.stack.length <= 1 || router.currentRoute.type === 'switch'){ - router = router.parentRoute.parent; - debug("Switching to parent router="+router.name); + if (router.parentRoute) { + router = router.parentRoute.parent; + debug("Switching to parent router="+router.name); + } else { + break; + } } if (router.pop()){ this.currentRouter = router; diff --git a/Router.js b/Router.js index 705058275..eef27e885 100644 --- a/Router.js +++ b/Router.js @@ -200,7 +200,7 @@ export default class Router { pop(num: number = 1){ if (this._stack.length <= num){ - throw new Error("Cannot pop(), stack=["+this._stack+"]"); + return false; } this.nextRoute = null; if (this.delegate.onPop && this.delegate.onPop(num)){ @@ -219,4 +219,4 @@ export default class Router { function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); -} \ No newline at end of file +}