mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nuxt): prevent fallthrough attributes on custom NuxtLink
(#19379)
This commit is contained in:
parent
d4a75240ac
commit
0be8cda77a
@ -211,20 +211,29 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (!isExternal.value) {
|
if (!isExternal.value) {
|
||||||
// Internal link
|
const routerLinkProps: Record<string, any> = {
|
||||||
return h(
|
|
||||||
resolveComponent('RouterLink'),
|
|
||||||
{
|
|
||||||
ref: process.server ? undefined : (ref: any) => { el!.value = ref?.$el },
|
ref: process.server ? undefined : (ref: any) => { el!.value = ref?.$el },
|
||||||
to: to.value,
|
to: to.value,
|
||||||
...((prefetched.value && !props.custom) ? { class: props.prefetchedClass || options.prefetchedClass } : {}),
|
|
||||||
activeClass: props.activeClass || options.activeClass,
|
activeClass: props.activeClass || options.activeClass,
|
||||||
exactActiveClass: props.exactActiveClass || options.exactActiveClass,
|
exactActiveClass: props.exactActiveClass || options.exactActiveClass,
|
||||||
replace: props.replace,
|
replace: props.replace,
|
||||||
ariaCurrentValue: props.ariaCurrentValue,
|
ariaCurrentValue: props.ariaCurrentValue,
|
||||||
custom: props.custom,
|
custom: props.custom
|
||||||
rel: props.rel
|
}
|
||||||
},
|
|
||||||
|
// `custom` API cannot support fallthrough attributes as the slot
|
||||||
|
// may render fragment or text root nodes (#14897, #19375)
|
||||||
|
if (!props.custom) {
|
||||||
|
if (prefetched.value) {
|
||||||
|
routerLinkProps.class = props.prefetchedClass || options.prefetchedClass
|
||||||
|
}
|
||||||
|
routerLinkProps.rel = props.rel
|
||||||
|
}
|
||||||
|
|
||||||
|
// Internal link
|
||||||
|
return h(
|
||||||
|
resolveComponent('RouterLink'),
|
||||||
|
routerLinkProps,
|
||||||
slots.default
|
slots.default
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ describe.skipIf(isWindows)('minimal nuxt application', () => {
|
|||||||
|
|
||||||
it('default server bundle size', async () => {
|
it('default server bundle size', async () => {
|
||||||
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||||
expect(stats.server.totalBytes).toBeLessThan(92900)
|
expect(stats.server.totalBytes).toBeLessThan(93000)
|
||||||
|
|
||||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||||
expect(modules.totalBytes).toBeLessThan(2722000)
|
expect(modules.totalBytes).toBeLessThan(2722000)
|
||||||
|
Loading…
Reference in New Issue
Block a user