@@ -55,6 +55,7 @@ describe('MatIcon', () => {
5555 IconWithBindingAndNgIf ,
5656 InlineIcon ,
5757 SvgIconWithUserContent ,
58+ IconWithLigatureAndSvgBinding ,
5859 ] ,
5960 providers : [ {
6061 provide : MAT_ICON_LOCATION ,
@@ -159,6 +160,19 @@ describe('MatIcon', () => {
159160 expect ( sortedClassNames ( matIconElement ) )
160161 . toEqual ( [ 'mat-icon' , 'mat-icon-no-color' , 'myfont' , 'notranslate' ] ) ;
161162 } ) ;
163+
164+ it ( 'should not clear the text of a ligature icon if the svgIcon is bound to something falsy' ,
165+ ( ) => {
166+ let fixture = TestBed . createComponent ( IconWithLigatureAndSvgBinding ) ;
167+
168+ const testComponent = fixture . componentInstance ;
169+ const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
170+ testComponent . iconName = undefined ;
171+ fixture . detectChanges ( ) ;
172+
173+ expect ( matIconElement . textContent . trim ( ) ) . toBe ( 'house' ) ;
174+ } ) ;
175+
162176 } ) ;
163177
164178 describe ( 'Icons from URLs' , ( ) => {
@@ -851,3 +865,8 @@ class InlineIcon {
851865class SvgIconWithUserContent {
852866 iconName : string | undefined = '' ;
853867}
868+
869+ @Component ( { template : '<mat-icon [svgIcon]="iconName">house</mat-icon>' } )
870+ class IconWithLigatureAndSvgBinding {
871+ iconName : string | undefined ;
872+ }
0 commit comments