You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ad70a67
Browse filesBrowse the repository at this point in the historyBrowse files
fix(experimental): resolve relative object locations against the current route (#2890)
* fix(experimental): resolve relative object locations against the current route
* test(experimental): resolve relative objects without a current location argument
Without the fix, these calls crash in production (TypeError reading 'name' of undefined).
Written by an AI agent (Claude Code). Not reviewed by a human.
* refactor(experimental): inline relative base in resolve to save bytes
Experimental size check: +1 B min, +1 B gzip, +4 B brotli vs main (was +34/+12/+8 with the helper function).
Written by an AI agent (Claude Code). Not reviewed by a human.
* feat(experimental): add dev diagnostic for relative locations without a current location
Replace the dev warning with VUE_ROUTER_R0127, which states how to fix the call. Production is unchanged: the diagnostic is dev-only (0 B).
Written by an AI agent (Claude Code). Not reviewed by a human.
* refactor(experimental): detect relative locations without a current route in dev only
The router now passes the current route for every relative location and no longer checks START_LOCATION. The dev-only check in the resolver reports VUE_ROUTER_R0127 when the current location is missing or has no route (START_LOCATION, or a no-match current route), instead of throwing 'Record not found'.
Experimental size check: -33 B min, -7 B gzip, -4 B brotli vs the previous commit. Smaller than main by 32 B min.
Written by an AI agent (Claude Code). Not reviewed by a human.
* fix(experimental): use free diagnostic code VUE_ROUTER_R0129
main now uses VUE_ROUTER_R0127 and R0128 for history diagnostics.
Written by an AI agent (Claude Code). Not reviewed by a human.
* fix: remove query params in relative navigations
* fix: keep aliases
Copy file name to clipboardExpand all lines: packages/docs/experimental/router-resolver.md
+20-7Lines changed: 20 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,21 +78,34 @@ An empty array is the same as a missing key: `{ tag: [] }` and `{}` give the sam
78
78
79
79
## Navigation and redirects
80
80
81
-
Relative string locations passed to `router.push()`, `router.replace()`, or `router.resolve()`use the current route as their base:
81
+
Relative locations passed to `router.push()`, `router.replace()`, `router.resolve()`, or `<RouterLink>`use the current route as their base. A relative location is a string that does not start with `/`, or an object without a `name` and without an absolute `path`:
82
82
83
83
```ts
84
84
// Current route: /users/posva
85
85
router.push('add') // /users/add
86
+
router.push({ path: 'add' }) // /users/add
86
87
```
87
88
88
-
Relative object locations need an explicit current location. Resolve them first, then navigate:
89
+
An object without a `name` or `path` keeps the current params, query, and hash unless the object overrides them. The `query` object is merged with the current query. It does not replace it:
`An error was thrown while matching "${p.path}" against the route "${p.name}". The route is skipped.`,
50
50
fix: 'Return null from match() to skip a route, or call miss() in a param parser. Fix the thrown error if it is a bug.',
51
51
},
52
+
VUE_ROUTER_R0129: {
53
+
why: (p: {location: string})=>
54
+
`Cannot resolve relative location ${p.location} without a "name": there is no current location, or the current location has no route. This crashes in production.`,
55
+
fix: 'Pass the location it is relative to as the second argument of resolve(), or use a location with a "name" or an absolute "path".',
56
+
},
52
57
VUE_ROUTER_R0125: {
53
58
why: (p: {name: string})=>
54
59
`The params, query, or hash do not match the route "${p.name}".`,
0 commit comments