Skip to content

Commit c531d02

Browse files
committedMar 24, 2025·
fix(Link): handle aria-current like NuxtLink / RouterLink
1 parent d73768b commit c531d02

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
 

‎src/runtime/components/Link.vue

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ defineOptions({ inheritAttrs: false })
102102
const props = withDefaults(defineProps<LinkProps>(), {
103103
as: 'button',
104104
type: 'button',
105+
ariaCurrentValue: 'page',
105106
active: undefined,
106107
activeClass: '',
107108
inactiveClass: ''
@@ -178,6 +179,7 @@ function resolveLinkClass({ route, isActive, isExactActive }: any) {
178179
<slot
179180
v-bind="{
180181
...$attrs,
182+
...(exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {}),
181183
as,
182184
type,
183185
disabled,
@@ -194,6 +196,7 @@ function resolveLinkClass({ route, isActive, isExactActive }: any) {
194196
v-else
195197
v-bind="{
196198
...$attrs,
199+
...(exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {}),
197200
as,
198201
type,
199202
disabled,

‎src/runtime/vue/components/Link.vue

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ defineOptions({ inheritAttrs: false })
103103
const props = withDefaults(defineProps<LinkProps>(), {
104104
as: 'button',
105105
type: 'button',
106+
ariaCurrentValue: 'page',
106107
active: undefined,
107108
activeClass: '',
108109
inactiveClass: ''
@@ -204,6 +205,7 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
204205
<slot
205206
v-bind="{
206207
...$attrs,
208+
...(exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {}),
207209
as,
208210
type,
209211
disabled,
@@ -217,6 +219,7 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
217219
v-else
218220
v-bind="{
219221
...$attrs,
222+
...(exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {}),
220223
as,
221224
type,
222225
disabled,

0 commit comments

Comments
 (0)
Please sign in to comment.