8000 feat(history): Reset history.current when all apps are destroyed by nightnei · Pull Request #3298 · vuejs/vue-router · GitHub
[go: up one dir, main page]

Skip to content

feat(history): Reset history.current when all apps are destroyed #3298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 31, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: split History.teardown method
  • Loading branch information
nightnei committed Aug 17, 2020
commit cac3e2c1d232ec725f38b9013107e31924879b50
10 changes: 9 additions & 1 deletion src/history/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,25 @@ export class History {
// Default implementation is empty
}

teardown () {
teardownListeners () {
// clean up event listeners
// https://github.com/vuejs/vue-router/issues/2341
this.listeners.forEach(cleanupListener => {
cleanupListener()
})
this.listeners = []
}

resetHistoryState () {
// reset current history route
// https://github.com/vuejs/vue-router/issues/3294
this.current = START
this.pending = null
}

teardown () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just put everything inside here as I don't think it makes sense to call teardownListeners or resetHistoryState separately

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@posva done

this.teardownListeners()
this.resetHistoryState()
}
}

Expand Down
0