_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
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 {
// 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 = {}
}
// 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
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()
}
failure
)
})
- .catch(() => {
- // TODO: same as above
- })
+ .catch(noop)
})
}
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),