fix(Link): properly pick all aria-* & data-* attrs

Resolves https://github.com/nuxt/ui-pro/issues/494, resolves #3007
This commit is contained in:
Benjamin Canac
2025-03-24 18:55:27 +01:00
parent 02694db29c
commit 2bef1e26c6

View File

@@ -127,9 +127,11 @@ export const getNuxtLinkProps = (props) => {
}
export const getULinkProps = (props) => {
const keys = [...Object.keys(nuxtLinkProps), ...Object.keys(uLinkProps), 'ariaLabel', 'title']
const keys = Object.keys(props)
const ariaKeys = keys.filter(key => key.startsWith('aria-'))
const dataKeys = keys.filter(key => key.startsWith('data-'))
return keys.reduce((acc, key) => {
return [...Object.keys(nuxtLinkProps), ...Object.keys(uLinkProps), ...ariaKeys, ...dataKeys].reduce((acc, key) => {
if (props[key] !== undefined) {
acc[key] = props[key]
}