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 8
8
< ng-content > </ ng-content >
9
9
10
10
< 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. -->
11
13
< label class ="mat-input-placeholder mat-form-field-placeholder "
12
14
[attr.for] ="_control.id "
15
+ [attr.aria-owns] ="_control.id "
13
16
[class.mat-empty] ="_control.empty && !_shouldAlwaysFloat "
14
17
[class.mat-form-field-empty] ="_control.empty && !_shouldAlwaysFloat "
15
18
[class.mat-float] ="_canPlaceholderFloat "
Original file line number Diff line number Diff line change @@ -224,6 +224,18 @@ describe('MdInput without forms', function () {
224
224
expect ( inputElement . id ) . toEqual ( labelElement . getAttribute ( 'for' ) ) ;
225
225
} ) ;
226
226
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
+
227
239
it ( 'should not overwrite existing id' , ( ) => {
228
240
let fixture = TestBed . createComponent ( MdInputWithId ) ;
229
241
fixture . detectChanges ( ) ;
You can’t perform that action at this time.
0 commit comments