Skip to content

Commit bfe8dcc

Browse files
Added comment explaining why href is _removed_ from an anchor when the anchor is disabled.
1 parent cb64009 commit bfe8dcc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ak-button/ak-button.template.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ type ButtonLinkProps = Pick<ButtonProps, "disabled" | "onClick" | "onKeydown"> &
1919

2020
export function linkTemplate(props: ButtonLinkProps) {
2121
const { href, target, disabled, download, rel, onClick, onKeydown } = props;
22+
23+
// The ARIA rules for disabled links specifies that “to communicate a link as ‘disabled,’ remove
24+
// the `href` attribute and style accordingly. Hence the `href=${ifDefined(...)}`. See:
25+
// https://www.w3.org/TR/html-aria/#example-communicate-a-disabled-link-with-aria
2226
return html`<a
2327
id="main"
2428
href=${ifDefined(disabled ? null : href)}

0 commit comments

Comments
 (0)