Skip to content

Commit

Permalink
fix(client): bypass chunk prefetching and client router for links exp…
Browse files Browse the repository at this point in the history
…licitly specifying target
  • Loading branch information
brc-dd committed Jul 1, 2023
1 parent 03855dd commit 1a266ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/client/app/composables/preFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export function usePrefetch() {
document
.querySelectorAll<HTMLAnchorElement | SVGAElement>('#app a')
.forEach((link) => {
const { target } = link
const { hostname, pathname } = new URL(
link.href instanceof SVGAnimatedString
? link.href.animVal
Expand All @@ -91,11 +90,14 @@ export function usePrefetch() {
if (
// only prefetch same tab navigation, since a new tab will load
// the lean js chunk instead.
target !== `_blank` &&
!link.target &&
// only prefetch inbound links
hostname === location.hostname
hostname === location.hostname &&
// bypass for links inside .vp-raw
!link.closest('.vp-raw')
) {
if (pathname !== location.pathname) {
console.log('here')
observer!.observe(link)
} else {
// No need to prefetch chunk for the current page, but also mark
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export function createRouter(
!e.shiftKey &&
!e.altKey &&
!e.metaKey &&
target !== `_blank` &&
!target &&
origin === currentUrl.origin &&
// don't intercept if non-html extension is present
!(extMatch && extMatch[0] !== '.html')
Expand Down

0 comments on commit 1a266ef

Please sign in to comment.