@@ -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
@@ -1493,11 +1508,13 @@ class PizzaMsg {
1493
1508
<mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content>
1494
1509
<mat-dialog-actions>
1495
1510
<button mat-dialog-close>Close</button>
1511
+ <button class="close-without-text" mat-dialog-close></button>
1512
+ <button class="close-icon-button" mat-icon-button mat-dialog-close>exit</button>
1496
1513
<button class="close-with-true" [mat-dialog-close]="true">Close and return true</button>
1497
1514
<button
1498
1515
class="close-with-aria-label"
1499
1516
aria-label="Best close button ever"
1500
- [mat-dialog-close]="true">Close </button>
1517
+ [mat-dialog-close]="true"></button>
1501
1518
<div mat-dialog-close>Should not close</div>
1502
1519
</mat-dialog-actions>
1503
1520
`
@@ -1511,11 +1528,13 @@ class ContentElementDialog {}
1511
1528
<mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content>
1512
1529
<mat-dialog-actions>
1513
1530
<button mat-dialog-close>Close</button>
1531
+ <button class="close-without-text" mat-dialog-close></button>
1532
+ <button class="close-icon-button" mat-icon-button mat-dialog-close>exit</button>
1514
1533
<button class="close-with-true" [mat-dialog-close]="true">Close and return true</button>
1515
1534
<button
1516
1535
class="close-with-aria-label"
1517
1536
aria-label="Best close button ever"
1518
- [mat-dialog-close]="true">Close </button>
1537
+ [mat-dialog-close]="true"></button>
1519
1538
<div mat-dialog-close>Should not close</div>
1520
1539
</mat-dialog-actions>
1521
1540
</ng-template>
0 commit comments