@@ -57,6 +57,7 @@ describe('MatIcon', () => {
57
57
IconWithBindingAndNgIf ,
58
58
InlineIcon ,
59
59
SvgIconWithUserContent ,
60
+ IconWithLigatureAndSvgBinding ,
60
61
] ,
61
62
providers : [ {
62
63
provide : MAT_ICON_LOCATION ,
@@ -161,6 +162,19 @@ describe('MatIcon', () => {
161
162
expect ( sortedClassNames ( matIconElement ) )
162
163
. toEqual ( [ 'mat-icon' , 'mat-icon-no-color' , 'myfont' , 'notranslate' ] ) ;
163
164
} ) ;
165
+
166
+ it ( 'should not clear the text of a ligature icon if the svgIcon is bound to something falsy' ,
167
+ ( ) => {
168
+ let fixture = TestBed . createComponent ( IconWithLigatureAndSvgBinding ) ;
169
+
170
+ const testComponent = fixture . componentInstance ;
171
+ const matIconElement = fixture . debugElement . nativeElement . querySelector ( 'mat-icon' ) ;
172
+ testComponent . iconName = undefined ;
173
+ fixture . detectChanges ( ) ;
174
+
175
+ expect ( matIconElement . textContent . trim ( ) ) . toBe ( 'house' ) ;
176
+ } ) ;
177
+
164
178
} ) ;
165
179
166
180
describe ( 'Icons from URLs' , ( ) => {
@@ -854,3 +868,8 @@ class InlineIcon {
854
868
class SvgIconWithUserContent {
855
869
iconName : string | undefined = '' ;
856
870
}
871
+
872
+ @Component ( { template : '<mat-icon [svgIcon]="iconName">house</mat-icon>' } )
873
+ class IconWithLigatureAndSvgBinding {
874
+ iconName : string | undefined ;
875
+ }
0 commit comments