fix: make active + ancestor links accessible (#1915)
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user