From: Eduardo San Martin Morote Date: Tue, 1 Jun 2021 22:02:28 +0000 (+0200) Subject: fix(link): catch errors X-Git-Tag: v4.0.9~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7b2156c7436f18d1a08694f502eb00b10029f1c;p=thirdparty%2Fvuejs%2Frouter.git fix(link): catch errors --- diff --git a/src/RouterLink.ts b/src/RouterLink.ts index aef8e176..dbee6205 100644 --- a/src/RouterLink.ts +++ b/src/RouterLink.ts @@ -17,7 +17,7 @@ import { isSameRouteLocationParams, isSameRouteRecord } from './location' import { routerKey, routeLocationKey } from './injectionSymbols' import { RouteRecord } from './matcher/types' import { NavigationFailure } from './errors' -import { isBrowser } from './utils' +import { isBrowser, noop } from './utils' export interface RouterLinkOptions { /** @@ -113,8 +113,12 @@ export function useLink(props: UseLinkOptions) { function navigate( e: MouseEvent = {} as MouseEvent ): Promise { - if (guardEvent(e)) - return router[unref(props.replace) ? 'replace' : 'push'](unref(props.to)) + if (guardEvent(e)) { + return router[unref(props.replace) ? 'replace' : 'push']( + unref(props.to) + // avoid uncaught errors are they are logged anyway + ).catch(noop) + } return Promise.resolve() }