fix: make active + ancestor links accessible (#1915)

This commit is contained in:
Marvin Hagemeister
2023-10-11 17:29:07 +02:00
committed by GitHub
parent 77bc15cb6f
commit 78b0b05fc3
3 changed files with 29 additions and 0 deletions
+2
View File
@@ -37,8 +37,10 @@ export function setActiveUrl(vnode: VNode, pathname: string): void {
const match = matchesUrl(pathname, hrefProp);
if (match === UrlMatchKind.Current) {
props[DATA_CURRENT] = "true";
props["aria-current"] = "page";
} else if (match === UrlMatchKind.Ancestor) {
props[DATA_ANCESTOR] = "true";
props["aria-current"] = "true";
}
}
}
+3
View File
@@ -568,13 +568,16 @@ function updateLinks(url: URL) {
if (match === UrlMatchKind.Current) {
link.setAttribute(DATA_CURRENT, "true");
link.setAttribute("aria-current", "page");
link.removeAttribute(DATA_ANCESTOR);
} else if (match === UrlMatchKind.Ancestor) {
link.setAttribute(DATA_ANCESTOR, "true");
link.setAttribute("aria-current", "true");
link.removeAttribute(DATA_CURRENT);
} else {
link.removeAttribute(DATA_CURRENT);
link.removeAttribute(DATA_ANCESTOR);
link.removeAttribute("aria-current");
}
});
}