Skip to content

Commit

Permalink
fix(switch): track aria-checked
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed Jun 18, 2020
1 parent 263bc66 commit 1980046
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/switch/src/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ export class Switch extends CheckboxBase {
protected firstUpdated(changes: PropertyValues): void {
super.firstUpdated(changes);
this.inputElement.setAttribute('role', 'switch');
this.inputElement.setAttribute(
'aria-checked',
this.checked ? 'true' : 'false'
);
}

protected updated(changes: PropertyValues): void {
if (changes.has('checked')) {
this.inputElement.setAttribute(
'aria-checked',
this.checked ? 'true' : 'false'
);
}
}
}

0 comments on commit 1980046

Please # to comment.