Skip to content

Commit

Permalink
refactor: remove old TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jul 2, 2020
1 parent d9dad0b commit bb9d0ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/matcher/index.ts
Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions src/router.ts
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = {}
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -794,9 +790,7 @@ export function createRouter(options: RouterOptions): Router {
failure
)
})
.catch(() => {
// TODO: same as above
})
.catch(noop)
})
}

Expand Down Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions src/utils/index.ts
Expand Up @@ -22,3 +22,5 @@ export function applyToParams(

return newParams
}

export let noop = () => {}

0 comments on commit bb9d0ee

Please sign in to comment.