4.0.12 (2021-10-14)
- devtools: display router view path (3ce3834), closes #1119
- warn: improve message for onBeforeRoute*() (7d5230e)
4.0.11 (2021-08-09)
- query: empty object with custom stringify (4dd2fbf)
- router: allow null | undefined for params (ebca15a)
- router: invalidate ongoing navigation when unmounting (d8fb7d0)
- types: Support
undefined
in NavigationGuardNext (#1059) (6cce232)
4.0.10 (2021-06-21)
- devtools: display components using
useLink()
(aab8c04), closes #1003 - link: expose useLink on RouterLink as internal (#1002) (57b1468)
4.0.9 (2021-06-16)
- guards: propagate lazy loading rejections (3d465cc)
- hash: force navigation restore on manual navigation (#921) (e08a0d0), closes #916
- link: catch errors (e7b2156)
- query: allow arbitrary keys in queries (a57b5f1), closes #880
- warn: drop unused params on string redirect (bed24df), closes #951
- devtools: group navigation errors (a776a84)
- errors: add to and from to router.onError()` (c76feab)
- errors: log errors when no error handlers (46a354e)
4.0.8 (2021-05-13)
This release is a correct tag and doesn't contain any extra changes.
4.0.7 (2021-05-13)
- $route: Make $route have an enumerable type (#912) (d90520e)
- devtools: stabilize record id (#897) (c6460f0)
- history: make properties enumerable (8e6ebdf)
- history: proper destroy in memory history (9d188aa)
- query: filter undefined values in arrays (df25fb5)
- query: prevent trailing & in query (#935) (885bb06)
- do not allow invalid hazardous keys in query (#880) (ecd52e0)
4.0.6 (2021-04-06)
- link: let vue merge attrs (4142871), closes #846
- link: use flush post in devtools watcher (4108814), closes #845
- types: allow currentLocation param in resolve (add6ce9)
- warn: throws if history is missing (#844) (dd8bf6c)
4.0.5 (2021-03-11)
- guards: avoid enter guards between aliases (0048b9b)
- guards: ensure beforeRouteUpdate works with aliases (#819) (45ecb20), closes #805
- view: correctly reuse instance guards (#795) (d4fde59)
- devtools: group navigations (d3b5dfb)
4.0.4 (2021-02-19)
- devtools: id and label (#742) (d034307)
- guards: vue-class-component call guards on first... (#755) (06f942d)
- matcher: force leading slash with optional param in multi segments (11c882f)
- warn: should not warn missing optional params in aliases (92f8901)
- types: make meta type safe with unknown (eef0472)
4.0.3 (2021-01-11)
- hash: allow base tag different from base parameter (85b1bff), closes #685
- link: use replace prop (6edba5c), closes #702
- types: expose RouteParamsRaw (09bbc89)
- warn: more specific warnings (2cd8d86)
- warn: warn defineAsyncComponent usage in routes (#682) (9520d66)
4.0.2 (2020-12-27)
- matcher: clear customRe after consuming buffer (#680) (4c0b825), closes #679
- router: allow replace to have query and hash (6a8ccb6), closes #668
- router: do not restore history when ... (db267be), closes #662
- router-view: disable inheritAttrs (1e58574), closes #674
- types: add missing exported types (034c71c)
- spread operator compatible (a2f3e91)
4.0.1 (2020-12-07)
- build: rollback rollup plugin commonjs (9486950)
4.0.0 (2020-12-07)
- router-view: properly use route prop when nested (b74051a)
- router-view: return one node when possible (d18e500), closes #537
- expose routerViewLocationKey as internal (f498646)
4.0.0-rc.6 (2020-11-30)
- devtools: improve active + match in routes inspector (9f59489)
- types: expose
LocationQueryValueRaw
as internal (dc02850)
4.0.0-rc.5 (2020-11-21)
4.0.0-rc.4 (2020-11-20)
- expose symbols as internals (ef62d96)
4.0.0-rc.3 (2020-11-14)
4.0.0-rc.2 (2020-11-05)
- expose injection symbols as internals (0056aca)
- devtools: add devtools plugin (894d50d)
- devtools: add more (ee07302)
- devtools: better search (5d68a29)
- devtools: support multiple router instances (2e5d0d4)
4.0.0-rc.1 (2020-10-23)
4.0.0-beta.13 (2020-10-02)
- encoding: decode hash in string location (11acb3d)
- encoding: differentiate keys and values in query (a967e42)
- encoding: keep decoded hash when resolving (1a8ffc1)
- hash: only pushState the hash part (2a14c19), closes #495
- warn: help migrating catch all routes (14e1eb9)
- print errors from lazy loading (f6db91a), closes #497
4.0.0-beta.12 (2020-09-25)
4.0.0-beta.11 (2020-09-20)
4.0.0-beta.10 (2020-09-18)
- history: gracefully handle empty state (cbcf2a9), closes #366
- types: better type for navigate (0384cb0)
- types: explicit types on navigate (36d218c)
- types: fix types for redirect records (a77f148)
- warn: correctly warn against unused next (47cd7b9)
- types: Rename ScrollBehavior to RouterScrollBehavior (9fc0996)
- router: remove partial Promise from router.go (6ed6eee)
- types: allow extending meta fields (#407) (706e84f)
- warn: point to scrollBehavior in message (70ce7fe)
- router: The
router.go()
methods doesn't return anything (like in Vue Router 3) anymore. The existing implementation was wrong as it would resolve the promise for the following navigation ifrouter.go()
was called with something that wasn't possible e.g.router.go(-20)
right after entering the application would not do anything. Even worse, the promise returned by that call would resolve after the next navigation. There is no proper native API to implement this promise-based api properly, but one can write a version that should work in most scenarios by setting up multiple hooks right before callingrouter.go()
:
export function go(delta) {
return new Promise((resolve, reject) => {
function popStateListener() {
clearTimeout(timeout)
}
window.addEventListener('popstate', popStateListener)
function clearHooks() {
removeAfterEach()
removeOnError()
window.removeEventListener('popstate', popStateListener)
}
// if the popstate event is not called, consider this a failure
const timeout = setTimeout(() => {
clearHooks()
reject(new Error('Failed to use router.go()'))
// It's unclear of what value would always work here
}, 10)
setImmediate
const removeAfterEach = router.afterEach((_to, _from, failure) => {
clearHooks()
resolve(failure)
})
const removeOnError = router.onError(err => {
clearHooks()
reject(err)
})
router.go(delta)
})
}
- types: there is already an existing type named
ScrollBehavior
, so we are renaming our type to avoid any confusions and allow the user to use both types at the same type (which given what the existingScrollBehavior
type is designed for, will likely happen).
4.0.0-beta.9 (2020-09-01)
Build related fixes
4.0.0-beta.8 (2020-09-01)
- router-view: reuse saved instances in different records (#446) (6554171)
- types: add HTML attributes for JSX (06f3f8f), closes #435
- types: allow components defined via defineComponent (#421) (e47c84c)
- router-view:
onBeforeRouteLeave
andonBeforeRouteUpdate
used to have access to the component instance throughinstance.proxy
but given that:- It has been marked as
internal
(vuejs/core#1849) - When using
setup
, all variables are accessible on the scope (and should be accessed that way because the code minimizes better) It has been removed to prevent wrong usage and lighten Vue Router
- It has been marked as
4.0.0-beta.7 (2020-08-19)
- encoding: encode partial params (eb04117)
- matcher: avoid trailing slash with optional params (faf0aab)
- types: append declare module (50ad404), closes #419
- vetur: update tags/attributes definition (#408) (df8b2b1)
- warn: warn against infinite redirections (e3dcc8d)
4.0.0-beta.6 (2020-08-05)
4.0.0-beta.5 (2020-08-03)
- resolve simple relative links (af1deaa)
- url: simple resolve relative location (69c44db)
- warn: warn if guard returns without calling next (6e16bdd)
4.0.0-beta.4 (2020-07-25)
- router-view: render the slot when there is no match (bae42d4), closes #385
- work on Edge by adding an argument to catch (#383) (9580bea)
4.0.0-beta.3 (2020-07-21)
- guards: call beforeRouteEnter once per named view (f2846ff)
- guards: remove registered update guards after leaving (41bffda)
- guards: skip update and leave guards of unmounted views (f22e70a)
- hash: allow url to contain search params before hash (ae8b289), closes #378
- errors: export isNavigationFailure (28a9b25)
- guards: allow guards to return a value instead of calling next (#343) (5cb209f)
- guards: wip context support in multi apps (34d7390)
4.0.0-beta.2 (2020-07-07)
Fix build cache issues
4.0.0-beta.1 (2020-07-03)
- hash: manual changes should trigger a navigation (93891ab), closes #346
- router-link: add missing prop custom in jsx (c6274ae)
- router-view: preserve keep-alive route guard this context (#344) (994c073)
- warn: warn when RouterView is wrapped with transition (e4b3fbe)
- guards: next callback beforeRouteEnter (d9dad0b)
- router: the history property was marked as internal already. Since we
need to pass the history instance to the router, we always have access to it,
differently from Vue Router 3 where the history was instantiated internally.
The history API was also internal (it wasn't documented), so this change
shouldn't be a problem as people shouldn't be relying on
router.history
in their apps. If you think this property is needed, please open an issue to discuss the use case. Note it's already accessible as you have to create it:
export const history = createWebHistory()
export const router = createRouter({ history, routes: [] })
- history: HistoryLocation is just a string now. It was pretty much an
internal property but it could be used inside
history.state
. It used to be an object{ fullPath: '/the-url' }
. And it's now just thefullPath
property.
4.0.0-alpha.14 (2020-07-01)
- hash: use relative links in hash mode (32c9590), closes #342
- query: do not normalize query with custom stringifyQuery (ea65066), closes #328
- query: isSameRouteLocation compares queries by string (6e1f0ea), closes #328
- redirect: allow redirect on routes witch children (e57b875)
- router: support multiple apps at the same time (565ec9d)
4.0.0-alpha.13 (2020-06-18)
- allow arbitrary selectors starting with # (14b859d)
- use assign to align with Vue browser support (#311) (f80b670), closes #304
- hash: use location.pathname (0078147), closes #261
- matcher: correct check when removing existing records on add (2c267f5)
- matcher: override records by name when adding (07100fc)
- scroll: avoid reusing scroll position (dfc1fb3)
- scroll: allow passing behavior option (12e9209)
- scroll: replace selector with el (ab8a01c)
- warn: warn if component is a promise (4b2bfa8)
- warn: warn when routes are not found (#279) (d125356)
- allow props for named views (dbe2344)
- warn: warn multiple params with same name (5c8cd6e)
- scroll: this change follows the RFC at vuejs/rfcs#176:
selector
is renamed intoel
el
also accepts anElement
left
andtop
are passed alongel
instead of inside an object passed asoffset
- scroll:
scrollBehavior
doesn't accept an object withx
andy
coordinates anymore. Instead it accepts an object likeScrollToOptions
withleft
andtop
properties. You can now also pass thebehavior
property to enable smooth scrolling in most browsers. - It is now necessary to escape id selectors like
explained at https://mathiasbynens.be/notes/css-escapes. This was
necessary to allow selectors like
#container > child
.
4.0.0-alpha.12 (2020-05-19)
- hash: allow base with non trailing slash (f5cc050), closes #247
- prevent error on initial navigation to //invalid (e72e4ba)
- warn: warn multiple leading slashes (87c5e53)
- hash: When providing a base for hash histories, it is now necessary
to include a trailing slash to create a url that starts with
/#/
, otherwise it will result in a url starting with#/
. This allows users to use the routing system directly in simple files without needing to configure a server at all:https://example.com/file.html
+base: 'file.html
will produce a final url ofhttps://example.com/file.html#/
https://example.com/folder
+base: 'folder
will produce a final url ofhttps://example.com/folder#/
https://example.com/folder
+base: 'folder/
will produce a final url ofhttps://example.com/folder/#/
4.0.0-alpha.11 (2020-05-12)
- scroll: change scrollRestoration if scrollBehavior is provided (5cf2e61)
- match base in a non-sensitive way (7087bbc)
- router: allow multiple router instance (24d3d49)
- router: unique first navigation with multi app (33172af)
- types: export NavigationGuardNext (#229) (888bf4d)
- explicit injection symbols in dev mode (#228) (fab88ee)
- support jsx and tsx for RouterLink and RouterView (1d3dce3), closes #226
- router: allow functional components for routes (096d864)
- scroll: scroll to the same location like regular links (5f22d4f)
- warn: warn if next was called multiple times (dce2612)
4.0.0-alpha.10 (2020-05-05)
- scroll: do not restore on push (3f79195)
- warn: warn invalid hash (fcf2365)
- allow numbers as params (ef0920a), closes #206
- router: allow global router classes (388735b)
- router: go, back and forward can be awaited (eb87757)
- warn: detect missing param in nested absolute paths (f5b5949)
- warn: warn for invalid path+params and redirect (91f4de9)
- warn: warn missing params in alias (186e275)
- warn: warn when params are provided alongside path (8a8ddf1)
4.0.0-alpha.9 (2020-04-29)
- Removed sourcemaps from build
4.0.0-alpha.8 (2020-04-29)
- default matcher options (cea397b)
- guards: preserve navigation options when redirecting (9effd81)
- html5: correctly preserve current history.state (0586394), closes #180
- link: make alias of empty child active (cfe5993)
- encode hash (85bb7e1)
- link: preserve the alias path (fffa585)
- matcher: merge params (d8a6b25), closes #189
- router: make redirect relative to target location (e878e91)
- router: preserve navigation options with redirects (9732758)
- view: render slot with no match (5873296)
- Link and View renamed to RouterLink and RouterView (030bbc4)
- link: make empty child active with adjacent children (4b813b1)
- router: add global pathOptions (7383564)
- add navigation duplicated failure (9570416)
- add onBeforeRouteUpdate (96c9503)
- resolve relative paths (eae833e)
- router: add back,forward,go (5e927b5)
- router: add beforeResolve (9697134)
- scroll: handle scroll on reload (617f131)
- use index access for strings (971fea4)
- exported components Link and View have been renamed to be include the Router prefix and to have the same export name as their component name
4.0.0-alpha.7 (2020-04-17)
- add
$route
and$router
types (a4f80aa) - add guards types (c7ccd5a)
- refactor navigation to comply with vuejs/rfcs#150 (290c3be)
- This follows the RFC at vuejs/rfcs#150
Summary:
router.afterEach
androuter.onError
are now the global equivalent ofrouter.push
/router.replace
as well as navigation through the interface (history.go()
). A navigation only rejects if there was an unexpected error. A navigation failure will still resolve the promise returned byrouter.push
and be exposed as the resolved value.
4.0.0-alpha.6 (2020-04-17)
- history: allow base with / and base tag (d7c71b5), closes #164
- history: allow hash history with no origin (760d216), closes #163
- scroll: only apply on browser (cf53192)
- revert history navigation if navigation is cancelled (d8a0d11)
- router: merge createHref into resolve (66b2db9)
- add this.$route (92dc18d)
- add this.$router (1807f30)
- scroll: handle scroll on popstate (181efe9)
- merge meta fields (72a052f)
- guards: support errors in navigation guards (23ed08d)
- router: hasRoute (ca02444)
- Revert "test: only call browser.end on the last test" (d3221f1)
- router: createHref is removed from the router. Instead, resolve
returns a location object with the corresponding
href
property
4.0.0-alpha.5 (2020-04-08)
- link: not active when matched is empty (acd644d)
- check query and hash when navigating (3862ad9)
- ignore order of keys in query and params (643bd15)
- skip initial guards with static redirect (c76bb93)
- types: add missing exported types (ec241f7), closes #147
- allow symbols as route record name (f42ab3f)
- link: activeClass and exactActiveClass props (d53b383)
- link: allow
custom
prop (874510b)
- Renamed types by removing suffix Normalized and using Raw instead
RouteLocation
->RouteLocationRaw
RouteLocationNormalized
->RouteLocation
RouteLocationNormalized
is now a location that can be displayed (not a static redirect)RouteLocationNormalizedResolved
->RouteLocationNormalizedLoaded
RouteRecord
->RouteRecordRaw
RouteRecordNormalized
->RouteRecord
RouteRecordNormalized
is now a record that is not a static redirect
4.0.0-alpha.4 (2020-03-28)
- history: use current history state when replacing (5d80209)
- export more types (1583d48), closes #137
- guards: free instances only if navigation is confirmed (d0514e1)
- hash: fix base position for hash routing (ba40b8f)
- initial location with base (d05208b)
- router: prevent duplicated navigation on aliases (e825586)
- allow passing state to history (ac1c96f)
- improve route access (baf266c)
- history: expose state on html5 (3f83607)
- matcher: remove aliases alongside the original record (26b71b2)
- router: support custom parseQuery and stringifyQuery (#136) (5dce7bc)
- view: add props option as boolean (7fe1e7d)
- view: allow passing props as a function (494fc5e)
- view: useView to customize router-view (06b0c34)
- allow true in
next
(d76c6aa) - invoke guards with the right context (7053413)
- lazy loading (6ecdc70)
- view: allow props as object in record (fd4dc06)
useRoute
now retrieves a reactive RouteLocationNormalized instead of a Ref. This means there is no need to use.value
when accessing the route. You still need to wrap it withtoRefs
if you want to expose parts of the route:setup () { return { params: toRefs(useRoute()).params } }
4.0.0-alpha.3 (2020-03-14)
- add missing type definitions
4.0.0-alpha.2 (2020-03-14)
- history: correct url when replacing current location (704b45e)
- link: allow attrs to override behavior (4cae9db)
- link: allow custom classes (#134) (392c295), closes #133
- link: navigate to the alias path (3284110)
- link: non active repeatable params (0ccbc1e)
- add aliasOf to normalized records (d9f3174)
- handle active/exact in Link (6f49dce)
- matcher: link aliases to their original record (e9eb648)
4.0.0-alpha.1 (2020-02-26)
- rename createHistory and createHashHistory (7dbebb6)
- add dynamic routing at router level (a7943c6)
-
createHistory
is now namedcreateWebHistory
.createHashHistory
is now namedcreateWebHashHistory
.Both createHistory and createHashHistory are renamed to better reflect that they must be used in a browser environment while createMemoryHistory doesn't.
4.0.0-alpha.0 (2020-02-26)
Breaking changes compared to [email protected]
mode: 'history'
->history: createHistory()
- Catch all routes (
/*
) must now be defined using a parameter with a custom regex:/:catchAll(.*)
keep-alive
is not yet supported- Partial support of per-component navigation guards. No
beforeRouteEnter
yet