Skip to content

Commit

Permalink
add the replace attribute in location for hooking in beforeEach
Browse files Browse the repository at this point in the history
  • Loading branch information
wanyaxing committed Nov 26, 2017
1 parent 09b772e commit 4bb9331
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/history/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export class HashHistory extends History {

replace (location: RawLocation, onComplete?: Function, onAbort?: Function) {
const { current: fromRoute } = this
if (typeof location === 'string'){
location = {path:location}
}
if (typeof location === 'object' && !location.replace){
location.replace = 1
}
this.transitionTo(location, route => {
replaceHash(route.fullPath)
handleScroll(this.router, route, fromRoute, false)
Expand Down
6 changes: 6 additions & 0 deletions src/history/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export class HTML5History extends History {

replace (location: RawLocation, onComplete?: Function, onAbort?: Function) {
const { current: fromRoute } = this
if (typeof location === 'string'){
location = {path:location}
}
if (typeof location === 'object' && !location.replace){
location.replace = 1
}
this.transitionTo(location, route => {
replaceState(cleanPath(this.base + route.fullPath))
handleScroll(this.router, route, fromRoute, false)
Expand Down
1 change: 1 addition & 0 deletions src/util/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function createRoute (
meta: (record && record.meta) || {},
path: location.path || '/',
hash: location.hash || '',
replace: location.replace || 0,
query,
params: location.params || {},
fullPath: getFullPath(location, stringifyQuery),
Expand Down

0 comments on commit 4bb9331

Please sign in to comment.