Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/router
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.2.3
Choose a base ref
...
head repository: vuejs/router
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.2.4
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Jul 6, 2023

  1. Copy the full SHA
    d60d36c View commit details
  2. release: vue-router@4.2.4

    posva committed Jul 6, 2023
    Copy the full SHA
    0f14b99 View commit details
6 changes: 6 additions & 0 deletions packages/router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [4.2.4](https://github.com/vuejs/router/compare/v4.2.3...v4.2.4) (2023-07-06)

### Bug Fixes

- allow removing guards within the guard ([d60d36c](https://github.com/vuejs/router/commit/d60d36c49bbbd308618926ff0131890bfed2cdff))

## [4.2.3](https://github.com/vuejs/router/compare/v4.2.2...v4.2.3) (2023-07-05)

### Performance Improvements
12 changes: 12 additions & 0 deletions packages/router/__tests__/guards/afterEach.spec.ts
Original file line number Diff line number Diff line change
@@ -65,4 +65,16 @@ describe('router.afterEach', () => {
)
expect(spy).toHaveBeenCalledTimes(2)
})

it('removing an afterEach guard within one does not affect others', async () => {
const spy1 = jest.fn()
const spy2 = jest.fn()
const router = createRouter({ routes })
router.afterEach(spy1)
const remove = router.afterEach(spy2)
spy1.mockImplementationOnce(remove)
await router.push('/foo')
expect(spy1).toHaveBeenCalledTimes(1)
expect(spy2).toHaveBeenCalledTimes(1)
})
})
2 changes: 1 addition & 1 deletion packages/router/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-router",
"version": "4.2.3",
"version": "4.2.4",
"main": "index.js",
"unpkg": "dist/vue-router.global.js",
"jsdelivr": "dist/vue-router.global.js",
6 changes: 3 additions & 3 deletions packages/router/src/router.ts
Original file line number Diff line number Diff line change
@@ -906,9 +906,9 @@ export function createRouter(options: RouterOptions): Router {
): void {
// navigation is confirmed, call afterGuards
// TODO: wrap with error handlers
for (const guard of afterGuards.list()) {
runWithContext(() => guard(to, from, failure))
}
afterGuards
.list()
.forEach(guard => runWithContext(() => guard(to, from, failure)))
}

/**
2 changes: 1 addition & 1 deletion packages/router/src/utils/callbacks.ts
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ export function useCallbacks<T>() {

return {
add,
list: () => handlers,
list: () => handlers.slice(),
reset,
}
}