Skip to content

Commit

Permalink
fix(router): remove app from $router.apps array once app destroyed (F…
Browse files Browse the repository at this point in the history
…ixes #2639)


Prevent destroyed apps from causing memory leak in `$router.apps` array.

Fixes #2639
  • Loading branch information
tmorehouse authored and posva committed Apr 11, 2019
1 parent 627027f commit 836c009
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ export default class VueRouter {

// main app already initialized.
if (this.app) {
return
app.$once('hook:destroyed', () {
// Clean out app from this.apps array once destroyed
const index = this.apps.indexOf(app)
if (index > -1) this.apps.splice(index, 1)
})
return
}

this.app = app
Expand Down

0 comments on commit 836c009

Please sign in to comment.