Skip to content

Commit

Permalink
Add aria-current attribute to active sidebar link
Browse files Browse the repository at this point in the history
  • Loading branch information
jhildenbiddle committed Oct 9, 2023
1 parent 61d8d87 commit 86ae787
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ export function Events(Base) {
const li = this.#nav[this.#getNavKey(path, id)];
const sidebar = dom.getNode('.sidebar');
const active = dom.find(sidebar, 'li.active');
active && active.classList.remove('active');
li && li.classList.add('active');
active?.classList.remove('active');
active?.removeAttribute('aria-current');
li?.classList.add('active');
li?.setAttribute('aria-current', 'page');
}

#scrollEl = dom.$.scrollingElement || dom.$.documentElement;
Expand Down Expand Up @@ -310,8 +312,10 @@ export function Events(Base) {
if (hash.indexOf(href) === 0 && !target) {
target = a;
dom.toggleClass(node, 'add', 'active');
node.setAttribute('aria-current', 'page');
} else {
dom.toggleClass(node, 'remove', 'active');
node.removeAttribute('aria-current');
}
});

Expand Down

0 comments on commit 86ae787

Please sign in to comment.