From 9ad735a3497a27aa8832d36ddb6b517402de6f65 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 28 Aug 2024 12:31:59 +0100 Subject: [PATCH] fix(nuxt): do not pass listeners to custom `NuxtLink` (#28738) --- packages/nuxt/src/app/components/nuxt-link.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/app/components/nuxt-link.ts b/packages/nuxt/src/app/components/nuxt-link.ts index d2b9ad0d25..f38ddbd777 100644 --- a/packages/nuxt/src/app/components/nuxt-link.ts +++ b/packages/nuxt/src/app/components/nuxt-link.ts @@ -381,13 +381,15 @@ export function defineNuxtLink (options: NuxtLinkOptions) { replace: props.replace, ariaCurrentValue: props.ariaCurrentValue, custom: props.custom, - onPointerenter: shouldPrefetch('interaction') ? prefetch.bind(null, undefined) : undefined, - onFocus: shouldPrefetch('interaction') ? prefetch.bind(null, undefined) : undefined, } // `custom` API cannot support fallthrough attributes as the slot // may render fragment or text root nodes (#14897, #19375) if (!props.custom) { + if (shouldPrefetch('interaction')) { + routerLinkProps.onPointerenter = prefetch.bind(null, undefined) + routerLinkProps.onFocus = prefetch.bind(null, undefined) + } if (prefetched.value) { routerLinkProps.class = props.prefetchedClass || options.prefetchedClass } @@ -427,6 +429,7 @@ export function defineNuxtLink (options: NuxtLinkOptions) { return slots.default({ href: href.value, navigate, + prefetch, get route () { if (!href.value) { return undefined }