Description
Reproduction
https://github.com/vuejs/router/blob/main/packages/router/__tests__/router.spec.ts#L300-L328
Steps to reproduce the bug
- Route with an optional parameter
- Set the parameter
- Unset the parameter with
undefined
Expected behavior
I would have expected the parameter to be unset as in versions before 4.2, but I know this might not have been the intended behaviour.
Actual behavior
This issue is about the changes in #1814
It is a bit of a mess, because several things come together.
- The documentation says
undefined
andnull
are stringified: 0c91292 - Before the change they where not stringified, but could actually be used to unset optional params in the current route.
- After the change they are actually removed instead of stringified.
Additional information
Whatever the original intented use was, the use-case of unsetting the value of an optional parameter was never properly documented.
In practice using undefined
worked and was used by us and others, so the change is causing breakages in real-world usages.
I checked and unsetting an optional parameter with ""
did work at least in 4.1.6, but I am not sure if it also did in earlier versions, when we first implemented this code.
Imho using the empty string as "not set" is bad practice and they should be normalized to undefined
instead.
Metadata
Assignees
Type
Projects
Status
📆 Planned