fix(ui): noPrefetch and prefetch warnings#1587
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThe 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/components/Link/Base.vue (1)
74-75:v-bind="props"leaks component-specific props onto the<a>element.When a component spreads all its props to a child component, any props not explicitly declared by that child become fallthrough attributes. Since
NuxtLinkrenders a single<a>root element, those undeclared props—such asvariant,size,block,classicon, andnoUnderline—automatically end up as non-standard DOM attributes on the rendered anchor tag.Additionally,
:to="to"on line 94 is redundant sincetois already included in thev-bind="props"spread.Replace
v-bind="props"with a filtered computed that forwards only whatNuxtLinkexpects:♻️ Proposed refactor — replace
v-bind="props"with a filtered passthroughIn
<script setup>, add after the computed properties:const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value) + +const nuxtLinkProps = computed(() => ({ + to: props.to, +}))In
<template>, remove the redundant:tobinding and switch to the filtered spread:<NuxtLink - v-bind="props" + v-bind="nuxtLinkProps" v-else class="group/link gap-x-1 items-center" :class="{ ... }" - :to="to" :aria-keyshortcuts="ariaKeyshortcuts" :target="isLinkExternal ? '_blank' : undefined" >Also applies to: 94–96
🔗 Linked issue
resolves #1585
🧭 Context
Anywhere LinkBase is used, the console is flooded with warnings about noPrefetch and prefetch conflicting in NuxtLink.
This PR removes
& NuxtLinkPropsfrom defineProps and declares only the props LinkBase actually needs.📚 Description
The warning is triggered because spreading & NuxtLinkProps into defineProps causes Vue to register all NuxtLink props with their defaults. When v-bind="props" is used to forward them to NuxtLink, both prefetch and noPrefetch are passed simultaneously, even when neither was explicitly provided by the consumer, triggering NuxtLink's conflict check on every render.