File tree 2 files changed +18
-0
lines changed 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,23 @@ describe('MatInput without forms', function () {
238
238
expect ( labelElement . getAttribute ( 'aria-owns' ) ) . toBe ( inputElement . id ) ;
239
239
} ) ;
240
240
241
+ it ( 'should add aria-required reflecting the required state' , ( ) => {
242
+ const fixture = TestBed . createComponent ( MatInputWithRequired ) ;
243
+ fixture . detectChanges ( ) ;
244
+
245
+ const inputElement : HTMLInputElement =
246
+ fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
247
+
248
+ expect ( inputElement . getAttribute ( 'aria-required' ) )
249
+ . toBe ( 'false' , 'Expected aria-required to reflect required state of false' ) ;
250
+
251
+ fixture . componentInstance . required = true ;
252
+ fixture . detectChanges ( ) ;
253
+
254
+ expect ( inputElement . getAttribute ( 'aria-required' ) )
255
+ . toBe ( 'true' , 'Expected aria-required to reflect required state of true' ) ;
256
+ } ) ;
257
+
241
258
it ( 'should not overwrite existing id' , ( ) => {
242
259
let fixture = TestBed . createComponent ( MatInputWithId ) ;
243
260
fixture . detectChanges ( ) ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ let nextUniqueId = 0;
59
59
'[readonly]' : 'readonly' ,
60
60
'[attr.aria-describedby]' : '_ariaDescribedby || null' ,
61
61
'[attr.aria-invalid]' : 'errorState' ,
62
+ '[attr.aria-required]' : 'required.toString()' ,
62
63
'(blur)' : '_focusChanged(false)' ,
63
64
'(focus)' : '_focusChanged(true)' ,
64
65
'(input)' : '_onInput()' ,
You can’t perform that action at this time.
0 commit comments