Skip to content

Commit

Permalink
fix(html5 history): going forward
Browse files Browse the repository at this point in the history
  • Loading branch information
AoDev committed Feb 18, 2019
1 parent 0368679 commit e5047d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ export default class Router {
if (goToOptions.goingBack) {
this.history = this.history.slice(1)
}
else if (goToOptions.action === 'POP') {
this.history = [updatedRequest].concat(this.history.slice(1))
}
else {
this.history = [updatedRequest].concat(this.history)
}
Expand All @@ -179,7 +182,7 @@ export default class Router {
*/
goBack () {
if (this.history.length > 1) {
this.goTo(this.history[1], {goingBack: true})
this.goTo(this.history[1], {action: 'POP', goingBack: true})
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/html5HistoryPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,7 @@ export function createHistory (router, options = {}) {
history.listen((location, action) => {
const newRequest = requestFromLocation(location)
if (isDifferentRequest(newRequest, router)) {
if (action === 'POP') {
router.goBack()
}
else if (action === 'PUSH') {
router.goTo(newRequest)
}
router.goTo(newRequest, {action})
}
})

Expand Down

0 comments on commit e5047d2

Please sign in to comment.