]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: remove old TODO
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 2 Jul 2020 20:05:48 +0000 (22:05 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 2 Jul 2020 20:05:48 +0000 (22:05 +0200)
src/matcher/index.ts
src/router.ts
src/utils/index.ts

index fb31f58427ace91838164237c969fb478443396d..4b4d626950c31ac46a0718b373be58f61e927496 100644 (file)
@@ -16,9 +16,7 @@ import {
   _PathParserOptions,
 } from './pathParserRanker'
 import { warn } from '../warning'
-import { assign } from '../utils'
-
-let noop = () => {}
+import { assign, noop } from '../utils'
 
 interface RouterMatcher {
   addRoute: (record: RouteRecordRaw, parent?: RouteRecordMatcher) => () => void
index 01e80b4fdeee6c2614e513e396550a7e72b01394..fcd1c3875274d6f82adad84821b4a1c98409a1d5 100644 (file)
@@ -31,7 +31,7 @@ import {
   NavigationRedirectError,
   isNavigationFailure,
 } from './errors'
-import { applyToParams, isBrowser, assign } from './utils'
+import { applyToParams, isBrowser, assign, noop } from './utils'
 import { useCallbacks } from './utils/callbacks'
 import { encodeParam, decode, encodeHash } from './encoding'
 import {
@@ -692,8 +692,6 @@ export function createRouter(options: RouterOptions): Router {
       // remove registered guards from removed matched records
       record.leaveGuards = []
       // free the references
-
-      // TODO: to refactor once keep-alive and transition can be supported
       record.instances = {}
     }
 
@@ -730,7 +728,6 @@ export function createRouter(options: RouterOptions): Router {
   // attach listener to history to trigger navigations
   function setupListeners() {
     removeHistoryListener = routerHistory.listen((to, _from, info) => {
-      // TODO: in dev try catch to correctly log the matcher error
       // cannot be a redirect route because it was in history
       const toLocation = resolve(to.fullPath) as RouteLocationNormalized
 
@@ -764,9 +761,8 @@ export function createRouter(options: RouterOptions): Router {
             pushWithRedirect(
               (error as NavigationRedirectError).to,
               toLocation
-            ).catch(() => {
-              // TODO: in dev show warning, in prod triggerError, same as initial navigation
-            })
+              // avoid an uncaught rejection
+            ).catch(noop)
             // avoid the then branch
             return Promise.reject()
           }
@@ -794,9 +790,7 @@ export function createRouter(options: RouterOptions): Router {
             failure
           )
         })
-        .catch(() => {
-          // TODO: same as above
-        })
+        .catch(noop)
     })
   }
 
@@ -921,7 +915,6 @@ export function createRouter(options: RouterOptions): Router {
       app.component('RouterLink', RouterLink)
       app.component('RouterView', RouterView)
 
-      // TODO: add tests
       app.config.globalProperties.$router = router
       Object.defineProperty(app.config.globalProperties, '$route', {
         get: () => unref(currentRoute),
index ee3385cb8f70fede112388a4d0e03240d8a19e5a..35a2b8d06773f36fe46f55c560af9a57b2c909c6 100644 (file)
@@ -22,3 +22,5 @@ export function applyToParams(
 
   return newParams
 }
+
+export let noop = () => {}