]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat(scroll): allow modifying scrollBehavior in options (#602)
authorEduardo San Martin Morote <posva@users.noreply.github.com>
Sat, 21 Nov 2020 09:47:45 +0000 (10:47 +0100)
committerGitHub <noreply@github.com>
Sat, 21 Nov 2020 09:47:45 +0000 (10:47 +0100)
this allows enhanceApp in vuepress to run after creating the router

src/router.ts

index 5af46bc6d51404fce57ec9a4e58c4deee56b2e78..f760df144df6659c6a920e785fcc0efb1e11032c 100644 (file)
@@ -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<NavigationGuardWithThis<undefined>>()
@@ -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<any> {
+    const { scrollBehavior } = options
     if (!isBrowser || !scrollBehavior) return Promise.resolve()
 
     let scrollPosition: _ScrollPositionNormalized | null =