@@ -1143,11 +1143,26 @@ describe('MatDialog', () => {
11431143 expect ( overlayContainerElement . querySelectorAll ( '.mat-dialog-container' ) . length ) . toBe ( 1 ) ;
11441144 } ) ;
11451145
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+
11461156 it ( 'should allow for a user-specified aria-label on the close button' , fakeAsync ( ( ) => {
11471157 let button = overlayContainerElement . querySelector ( '.close-with-aria-label' ) ! ;
11481158 expect ( button . getAttribute ( 'aria-label' ) ) . toBe ( 'Best close button ever' ) ;
11491159 } ) ) ;
11501160
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+
11511166 it ( 'should override the "type" attribute of the close button' , ( ) => {
11521167 let button = overlayContainerElement . querySelector ( 'button[mat-dialog-close]' ) ! ;
11531168
@@ -1448,11 +1463,13 @@ class PizzaMsg {
14481463 <mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content>
14491464 <mat-dialog-actions>
14501465 <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>
14511468 <button class="close-with-true" [mat-dialog-close]="true">Close and return true</button>
14521469 <button
14531470 class="close-with-aria-label"
14541471 aria-label="Best close button ever"
1455- [mat-dialog-close]="true">Close </button>
1472+ [mat-dialog-close]="true"></button>
14561473 <div mat-dialog-close>Should not close</div>
14571474 </mat-dialog-actions>
14581475 `
@@ -1466,11 +1483,13 @@ class ContentElementDialog {}
14661483 <mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content>
14671484 <mat-dialog-actions>
14681485 <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>
14691488 <button class="close-with-true" [mat-dialog-close]="true">Close and return true</button>
14701489 <button
14711490 class="close-with-aria-label"
14721491 aria-label="Best close button ever"
1473- [mat-dialog-close]="true">Close </button>
1492+ [mat-dialog-close]="true"></button>
14741493 <div mat-dialog-close>Should not close</div>
14751494 </mat-dialog-actions>
14761495 </ng-template>
0 commit comments