From: Eduardo San Martin Morote Date: Sat, 21 Nov 2020 09:47:45 +0000 (+0100) Subject: feat(scroll): allow modifying scrollBehavior in options (#602) X-Git-Tag: v4.0.0-rc.5~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6651f5f954c8ecaf1a77ec209d5aba06343e867;p=thirdparty%2Fvuejs%2Frouter.git feat(scroll): allow modifying scrollBehavior in options (#602) this allows enhanceApp in vuepress to run after creating the router --- diff --git a/src/router.ts b/src/router.ts index 5af46bc6..f760df14 100644 --- a/src/router.ts +++ b/src/router.ts @@ -333,7 +333,6 @@ export function createRouter(options: RouterOptions): Router { const matcher = createRouterMatcher(options.routes, options) let parseQuery = options.parseQuery || originalParseQuery let stringifyQuery = options.stringifyQuery || originalStringifyQuery - let { scrollBehavior } = options let routerHistory = options.history const beforeGuards = useCallbacks>() @@ -345,7 +344,7 @@ export function createRouter(options: RouterOptions): Router { let pendingLocation: RouteLocation = START_LOCATION_NORMALIZED // leave the scrollRestoration if no scrollBehavior is provided - if (isBrowser && scrollBehavior && 'scrollRestoration' in history) { + if (isBrowser && options.scrollBehavior && 'scrollRestoration' in history) { history.scrollRestoration = 'manual' } @@ -1016,6 +1015,7 @@ export function createRouter(options: RouterOptions): Router { isPush: boolean, isFirstNavigation: boolean ): Promise { + const { scrollBehavior } = options if (!isBrowser || !scrollBehavior) return Promise.resolve() let scrollPosition: _ScrollPositionNormalized | null =