@@ -55,6 +55,7 @@ describe('MatIcon', () => {
55
55
IconWithBindingAndNgIf ,
56
56
InlineIcon ,
57
57
SvgIconWithUserContent ,
58
+ IconWithLigatureAndSvgBinding ,
58
59
] ,
59
60
providers : [ {
60
61
provide : MAT_ICON_LOCATION ,
@@ -159,6 +160,19 @@ describe('MatIcon', () => {
159
160
expect ( sortedClassNames ( matIconElement ) )
160
161
. toEqual ( [ 'mat-icon' , 'mat-icon-no-color' , 'myfont' , 'notranslate' ] ) ;
161
162
} ) ;
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
+
162
176
} ) ;
163
177
164
178
describe ( 'Icons from URLs' , ( ) => {
@@ -851,3 +865,8 @@ class InlineIcon {
851
865
class SvgIconWithUserContent {
852
866
iconName : string | undefined = '' ;
853
867
}
868
+
869
+ @Component ( { template : '<mat-icon [svgIcon]="iconName">house</mat-icon>' } )
870
+ class IconWithLigatureAndSvgBinding {
871
+ iconName : string | undefined ;
872
+ }
0 commit comments