Skip to content

Commit

Permalink
fix(router): check $router.beforeEach exists before using (#20549)
Browse files Browse the repository at this point in the history
Co-authored-by: John Leider <[email protected]>
  • Loading branch information
sgpinkus and johnleider authored Jan 24, 2025
1 parent db9fb77 commit bcce042
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vuetify/src/composables/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ export function useBackButton (router: Router | undefined, cb: (next: Navigation
let removeBefore: (() => void) | undefined
let removeAfter: (() => void) | undefined

if (IN_BROWSER) {
if (IN_BROWSER && router?.beforeEach) {
nextTick(() => {
window.addEventListener('popstate', onPopstate)
removeBefore = router?.beforeEach((to, from, next) => {
removeBefore = router.beforeEach((to, from, next) => {
if (!inTransition) {
setTimeout(() => popped ? cb(next) : next())
} else {
Expand Down

0 comments on commit bcce042

Please sign in to comment.