File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 88 < ng-content > </ ng-content >
99
1010 < span class ="mat-input-placeholder-wrapper mat-form-field-placeholder-wrapper ">
11+ <!-- We add aria-owns as a workaround for an issue in JAWS & NVDA where the label isn't
12+ read if it comes before the control in the DOM. -->
1113 < label class ="mat-input-placeholder mat-form-field-placeholder "
1214 [attr.for] ="_control.id "
15+ [attr.aria-owns] ="_control.id "
1316 [class.mat-empty] ="_control.empty && !_shouldAlwaysFloat "
1417 [class.mat-form-field-empty] ="_control.empty && !_shouldAlwaysFloat "
1518 [class.mat-float] ="_canPlaceholderFloat "
Original file line number Diff line number Diff line change @@ -224,6 +224,18 @@ describe('MdInput without forms', function () {
224224 expect ( inputElement . id ) . toEqual ( labelElement . getAttribute ( 'for' ) ) ;
225225 } ) ;
226226
227+ it ( 'should add aria-owns to the label for the associated control' , ( ) => {
228+ let fixture = TestBed . createComponent ( MdInputTextTestController ) ;
229+ fixture . detectChanges ( ) ;
230+
231+ const inputElement : HTMLInputElement =
232+ fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
233+ const labelElement : HTMLInputElement =
234+ fixture . debugElement . query ( By . css ( 'label' ) ) . nativeElement ;
235+
236+ expect ( labelElement . getAttribute ( 'aria-owns' ) ) . toBe ( inputElement . id ) ;
237+ } ) ;
238+
227239 it ( 'should not overwrite existing id' , ( ) => {
228240 let fixture = TestBed . createComponent ( MdInputWithId ) ;
229241 fixture . detectChanges ( ) ;
You can’t perform that action at this time.
0 commit comments