@@ -1143,11 +1143,26 @@ describe('MatDialog', () => {
1143
1143
expect ( overlayContainerElement . querySelectorAll ( '.mat-dialog-container' ) . length ) . toBe ( 1 ) ;
1144
1144
} ) ;
1145
1145
1146
+ it ( 'should set an aria-label on a button without text' , fakeAsync ( ( ) => {
1147
+ let button = overlayContainerElement . querySelector ( '.close-without-text' ) ! ;
1148
+ expect ( button . getAttribute ( 'aria-label' ) ) . toBeTruthy ( ) ;
1149
+ } ) ) ;
1150
+
1151
+ it ( 'should not have an aria-label if a button has text' , fakeAsync ( ( ) => {
1152
+ let button = overlayContainerElement . querySelector ( '[mat-dialog-close]' ) ! ;
1153
+ expect ( button . getAttribute ( 'aria-label' ) ) . toBeFalsy ( ) ;
1154
+ } ) ) ;
1155
+
1146
1156
it ( 'should allow for a user-specified aria-label on the close button' , fakeAsync ( ( ) => {
1147
1157
let button = overlayContainerElement . querySelector ( '.close-with-aria-label' ) ! ;
1148
1158
expect ( button . getAttribute ( 'aria-label' ) ) . toBe ( 'Best close button ever' ) ;
1149
1159
} ) ) ;
1150
1160
1161
+ it ( 'should always have an aria-label on a mat-icon-button' , fakeAsync ( ( ) => {
1162
+ let button = overlayContainerElement . querySelector ( '.close-icon-button' ) ! ;
1163
+ expect ( button . getAttribute ( 'aria-label' ) ) . toBeTruthy ( ) ;
1164
+ } ) ) ;
1165
+
1151
1166
it ( 'should override the "type" attribute of the close button' , ( ) => {
1152
1167
let button = overlayContainerElement . querySelector ( 'button[mat-dialog-close]' ) ! ;
1153
1168
@@ -1448,11 +1463,13 @@ class PizzaMsg {
1448
1463
<mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content>
1449
1464
<mat-dialog-actions>
1450
1465
<button mat-dialog-close>Close</button>
1466
+ <button class="close-without-text" mat-dialog-close></button>
1467
+ <button class="close-icon-button" mat-icon-button mat-dialog-close>exit</button>
1451
1468
<button class="close-with-true" [mat-dialog-close]="true">Close and return true</button>
1452
1469
<button
1453
1470
class="close-with-aria-label"
1454
1471
aria-label="Best close button ever"
1455
- [mat-dialog-close]="true">Close </button>
1472
+ [mat-dialog-close]="true"></button>
1456
1473
<div mat-dialog-close>Should not close</div>
1457
1474
</mat-dialog-actions>
1458
1475
`
@@ -1466,11 +1483,13 @@ class ContentElementDialog {}
1466
1483
<mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content>
1467
1484
<mat-dialog-actions>
1468
1485
<button mat-dialog-close>Close</button>
1486
+ <button class="close-without-text" mat-dialog-close></button>
1487
+ <button class="close-icon-button" mat-icon-button mat-dialog-close>exit</button>
1469
1488
<button class="close-with-true" [mat-dialog-close]="true">Close and return true</button>
1470
1489
<button
1471
1490
class="close-with-aria-label"
1472
1491
aria-label="Best close button ever"
1473
- [mat-dialog-close]="true">Close </button>
1492
+ [mat-dialog-close]="true"></button>
1474
1493
<div mat-dialog-close>Should not close</div>
1475
1494
</mat-dialog-actions>
1476
1495
</ng-template>
0 commit comments