From: Eduardo San Martin Morote Date: Thu, 2 Jul 2020 20:05:48 +0000 (+0200) Subject: refactor: remove old TODO X-Git-Tag: v4.0.0-beta.1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb9d0eee17e5f7d4424413708c58af767d44449d;p=thirdparty%2Fvuejs%2Frouter.git refactor: remove old TODO --- diff --git a/src/matcher/index.ts b/src/matcher/index.ts index fb31f584..4b4d6269 100644 --- a/src/matcher/index.ts +++ b/src/matcher/index.ts @@ -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 diff --git a/src/router.ts b/src/router.ts index 01e80b4f..fcd1c387 100644 --- a/src/router.ts +++ b/src/router.ts @@ -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), diff --git a/src/utils/index.ts b/src/utils/index.ts index ee3385cb..35a2b8d0 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -22,3 +22,5 @@ export function applyToParams( return newParams } + +export let noop = () => {}