Skip to content

Commit

Permalink
Set modus-switch's aria-checked value to "true" and "false"
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin O'Neil authored and Austin O'Neil committed Apr 18, 2024
1 parent 107b4c0 commit caf457f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ describe('modus-switch', () => {
const input = await page.find('modus-switch >>> input');
expect(await modusSwitch.getProperty('checked')).toBeTruthy();
expect(await input.getProperty('checked')).toBeTruthy();
expect(await input.getAttribute('aria-checked').toLowerCase()).toEqual('true');

await element.click();
await page.waitForChanges();

expect(await modusSwitch.getProperty('checked')).toBeFalsy();
expect(await input.getProperty('checked')).toBeFalsy();
expect(await input.getAttribute('aria-checked').toLowerCase()).toEqual('false');
});
it('renders with medium size', async () => {
const page = await newE2EPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('modus-switch', () => {
<div class="switch">
<span class="slider"></span>
</div>
<input role="switch" type="checkbox">
<input aria-checked="false" role="switch" type="checkbox">
</div>
</mock:shadow-root>
</modus-switch>
Expand All @@ -33,7 +33,7 @@ describe('modus-switch', () => {
<div class="switch">
<span class="slider"></span>
</div>
<input role="switch" aria-disabled="true" disabled type="checkbox">
<input aria-checked="false" role="switch" aria-disabled="true" disabled type="checkbox">
</div>
</mock:shadow-root>
</modus-switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ModusSwitch {
@Prop() ariaLabel: string | null;

/** (optional) Whether the switch is checked. */
@Prop({ mutable: true }) checked: boolean;
@Prop({ mutable: true }) checked = false;

/** (optional) Whether the switch is disabled. */
@Prop() disabled: boolean;
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ModusSwitch {
<span class={`slider`}></span>
</div>
<input
aria-checked={this.checked}
aria-checked={String(this.checked)}
aria-disabled={this.disabled ? 'true' : undefined}
aria-label={this.ariaLabel}
checked={this.checked}
Expand Down

0 comments on commit caf457f

Please sign in to comment.