Skip to content
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

Remove event listeners of previous route component #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
6 changes: 6 additions & 0 deletions src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Log } from '../lib/log.js'
import { stage } from '../launch.js'
import Focus from '../focus.js'
import Announcer from '../announcer/announcer.js'
import eventListeners from '../lib/eventListeners.js'

export let currentRoute
export let navigating = false
Expand Down Expand Up @@ -143,6 +144,11 @@ export const navigate = async function () {
route.transition = route.transition(previousRoute, route)
}

// remove event listeners from current active view
if (previousRoute) {
eventListeners.removeListeners(this.activeView)
}

let holder
let { view, focus } = cacheMap.get(route) || {}

Expand Down