Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #138 from brunobasto/pr-2
Browse files Browse the repository at this point in the history
SF
  • Loading branch information
eduardolundgren authored Jul 7, 2016
2 parents f51642c + fbb3321 commit e6aeebc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,12 @@ class App extends EventEmitter {
handleNavigateError_(path, nextScreen, err) {
console.log('Navigation error for [' + nextScreen + '] (' + err + ')');
if (!utils.isCurrentBrowserPath(path)) {
this.removeScreen(path);
if (this.pendingNavigate) {
this.pendingNavigate.thenAlways(() => this.removeScreen(path), this);
}
else {
this.removeScreen(path);
}
}
}

Expand Down
30 changes: 30 additions & 0 deletions test/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,36 @@ describe('App', function() {
.cancel();
});

it('should wait for pendingNavigate before removing screen on double back navigation', (done) => {
class CacheScreen extends Screen {
constructor() {
super();
this.cacheable = true;
}
}

var app = new App();
this.app = app;
app.addRoutes(new Route('/path1', CacheScreen));
app.addRoutes(new Route('/path2', CacheScreen));
app.addRoutes(new Route('/path3', CacheScreen));

app.navigate('/path1')
.then(() => app.navigate('/path2'))
.then(() => app.navigate('/path3'))
.then(() => {
app.on('endNavigate', () => {
assert.ok(app.screens['/path2']);
app.pendingNavigate.then(() => {
assert.ok(!app.screens['/path2']);
done();
});
});
globals.window.history.back();
globals.window.history.back();
});
});

});

var canScrollIFrame_ = false;
Expand Down

0 comments on commit e6aeebc

Please sign in to comment.