Skip to content

Commit 10bd6da

Browse files
devversionmmalerba
authored andcommitted
fix(slide-toggle): consistent naming of aria attributes (#2688)
* fix(slide-toggle): consistent naming of aria attributes * Ensures that the slide-toggle uses consistent attribute naming. Consistent with the native inputs and other Material components. * Change back to tabIndex
1 parent be0da09 commit 10bd6da

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/lib/slide-toggle/slide-toggle.spec.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ describe('MdSlideToggle', () => {
189189
expect(inputElement.id).toMatch(/md-slide-toggle-[0-9]+-input/g);
190190
});
191191

192+
it('should forward the tabIndex to the underlying input', () => {
193+
fixture.detectChanges();
194+
195+
expect(inputElement.tabIndex).toBe(0);
196+
197+
testComponent.slideTabindex = 4;
198+
fixture.detectChanges();
199+
200+
expect(inputElement.tabIndex).toBe(4);
201+
});
202+
192203
it('should forward the specified name to the input', () => {
193204
testComponent.slideName = 'myName';
194205
fixture.detectChanges();
@@ -570,8 +581,9 @@ function dispatchFocusChangeEvent(eventName: string, element: HTMLElement): void
570581
[id]="slideId"
571582
[checked]="slideChecked"
572583
[name]="slideName"
573-
[ariaLabel]="slideLabel"
574-
[ariaLabelledby]="slideLabelledBy"
584+
[aria-label]="slideLabel"
585+
[aria-labelledby]="slideLabelledBy"
586+
[tabIndex]="slideTabindex"
575587
(change)="onSlideChange($event)"
576588
(click)="onSlideClick($event)">
577589
@@ -589,6 +601,7 @@ class SlideToggleTestApp {
589601
slideName: string;
590602
slideLabel: string;
591603
slideLabelledBy: string;
604+
slideTabindex: number;
592605
lastEvent: MdSlideToggleChange;
593606

594607
onSlideClick(event: Event) {}

src/lib/slide-toggle/slide-toggle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ export class MdSlideToggle implements AfterContentInit, ControlValueAccessor {
8686
@Input() tabIndex: number = 0;
8787

8888
/** Used to set the aria-label attribute on the underlying input element. */
89-
@Input() ariaLabel: string = null;
89+
@Input('aria-label') ariaLabel: string = null;
9090

9191
/** Used to set the aria-labelledby attribute on the underlying input element. */
92-
@Input() ariaLabelledby: string = null;
92+
@Input('aria-labelledby') ariaLabelledby: string = null;
9393

9494
/** Whether the slide-toggle is disabled. */
9595
@Input()

0 commit comments

Comments
 (0)