Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export default {
? classes[exactActiveClass]
: isIncludedRoute(current, compareTarget)

const ariaCurrentValue = classes[exactActiveClass] ? 'page' : null

const handler = e => {
if (guardEvent(e)) {
if (this.replace) {
Expand Down Expand Up @@ -117,7 +119,7 @@ export default {

if (this.tag === 'a') {
data.on = on
data.attrs = { href }
data.attrs = { href, 'aria-current': ariaCurrentValue }
} else {
// find the first <a> child and apply listener and href
const a = findAnchor(this.$slots.default)
Expand Down Expand Up @@ -145,6 +147,7 @@ export default {

const aAttrs = (a.data.attrs = extend({}, a.data.attrs))
aAttrs.href = href
aAttrs['aria-current'] = ariaCurrentValue
} else {
// doesn't have <a> child, apply listener to self
data.on = on
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/specs/active-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ module.exports = {
browser.assert
.cssClassPresent(`li:nth-child(${i}) a`, 'router-link-exact-active')
.assert.cssClassPresent(`li:nth-child(${i}) a`, 'router-link-active')
.assert.attributeEquals(`li:nth-child(${i}) a`, 'aria-current', 'page')
})
exactActiveLI &&
exactActiveLI.forEach(i => {
browser.assert
.cssClassPresent(`li:nth-child(${i})`, 'router-link-exact-active')
.assert.cssClassPresent(`li:nth-child(${i})`, 'router-link-active')
.assert.attributeEquals(`li:nth-child(${i}) a`, 'aria-current', 'page')
})
}
}
Expand Down