Skip to content

Commit d6651f5

Browse files
authored
feat(scroll): allow modifying scrollBehavior in options (vuejs#602)
this allows enhanceApp in vuepress to run after creating the router
1 parent 4fcf59e commit d6651f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ export function createRouter(options: RouterOptions): Router {
333333
const matcher = createRouterMatcher(options.routes, options)
334334
let parseQuery = options.parseQuery || originalParseQuery
335335
let stringifyQuery = options.stringifyQuery || originalStringifyQuery
336-
let { scrollBehavior } = options
337336
let routerHistory = options.history
338337

339338
const beforeGuards = useCallbacks<NavigationGuardWithThis<undefined>>()
@@ -345,7 +344,7 @@ export function createRouter(options: RouterOptions): Router {
345344
let pendingLocation: RouteLocation = START_LOCATION_NORMALIZED
346345

347346
// leave the scrollRestoration if no scrollBehavior is provided
348-
if (isBrowser && scrollBehavior && 'scrollRestoration' in history) {
347+
if (isBrowser && options.scrollBehavior && 'scrollRestoration' in history) {
349348
history.scrollRestoration = 'manual'
350349
}
351350

@@ -1016,6 +1015,7 @@ export function createRouter(options: RouterOptions): Router {
10161015
isPush: boolean,
10171016
isFirstNavigation: boolean
10181017
): Promise<any> {
1018+
const { scrollBehavior } = options
10191019
if (!isBrowser || !scrollBehavior) return Promise.resolve()
10201020

10211021
let scrollPosition: _ScrollPositionNormalized | null =

0 commit comments

Comments
 (0)