Skip to content

Commit

Permalink
Merge pull request #154 from aksonov/delian-patch-fast-click
Browse files Browse the repository at this point in the history
Stop popping if there is nowhere to go
  • Loading branch information
Pavlo Aksonov committed Jan 28, 2016
2 parents 28b94b8 + 0fe8ba5 commit 2594f96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand All @@ -219,4 +219,4 @@ export default class Router {

function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
}

0 comments on commit 2594f96

Please sign in to comment.