From 1980046ab0f791bfe1e147c855f43ddf2d2a424e Mon Sep 17 00:00:00 2001 From: Westbrook Date: Thu, 18 Jun 2020 18:21:37 -0400 Subject: [PATCH] fix(switch): track aria-checked --- packages/switch/src/switch.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/switch/src/switch.ts b/packages/switch/src/switch.ts index fd4f0d3549..b1ecdfc4d8 100644 --- a/packages/switch/src/switch.ts +++ b/packages/switch/src/switch.ts @@ -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' + ); + } } }