Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5k
add the replace attribute in location for hooking in beforeEach#1906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:dev
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
e... |
posva commentedDec 6, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hey, sorry for the delay. What are you trying to achieve? The issue you linked is closed. Why are you always setting replace to true if location is an object? |
If somebody reset the path in beforeEach, the new path will be open as push type, actually, it will be puzzled if the original router path is replace type. In this PR, the replace setting of location in the $router.replace() will be set as true, so the developer can find the route's type in the beforeEach hooking. |
Aaah, is the issue you're referring to#1620? |
yes. And the vue-router has supported the replace type checking in the route guards next() in this commit:d53ec3c This pr is an expand of that commit. |
ok, could you add some tests to make sure the property is added in different scenarios but not others? (push/replace/calling it with next) |
I have added an example for this commit. |
luozhihua commentedMay 2, 2018
Is there any progress? I waiting for this PR to be merged for a long time. |
choegyumin commentedJun 26, 2018
I am waiting for this PR to be merged too.. |
This will probably come along with other changes that would allow knowing what kind of navigation happened (back, forward, push, replace) |
hxlniada commentedAug 4, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@posva is there any plan to add these features? we are waiting for this feature too too too too too long. almost a year. |
reckert commentedApr 8, 2019
Around one year after the last post, I would like to ask if this branch will be merged some day. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks! There is no need to add a new e2e spec, we can add a test to the existingbasic
e2e test instead
if (typeof location === 'object' && !location.replace) { | ||
(location: Object).replace = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Since location is an object at this point, we can directly setreplace
to true
if(typeoflocation==='object'&&!location.replace){ | |
(location:Object).replace=true | |
} | |
(location:Object).replace=true |
@@ -52,10 +52,13 @@ export function normalizeLocation ( | |||
hash = `#${hash}` | |||
} | |||
const replace = next.replace || false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
no need to create a new variable. It can also be written as!!next.replace
@@ -23,6 +23,7 @@ export function createRoute ( | |||
meta: (record && record.meta) || {}, | |||
path: location.path || '/', | |||
hash: location.hash || '', | |||
replace: location.replace || false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
replace:location.replace||false, | |
replace:!!location.replace, |
Uh oh!
There was an error while loading.Please reload this page.
Closes#1620