File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,6 @@ <h3>Animation</h3>
2222< p > Slide to turn up the magic.</ p >
2323< fa-icon [icon] ="faMagic " transform ="rotate-{{magicLevel}} "> </ fa-icon >
2424< input type ='range ' [value] ="magicLevel " (input) ="magicLevel=$event.target.value "/>
25+ < h3 > Intentionally Missing Icon</ h3 >
26+ < p > Expect to see an error on the JavaScript console, and nothing shown between these bars: |< fa-icon [icon] ="faFluzzle "> </ fa-icon > |</ p >
27+
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111 RotateProp ,
1212 SizeProp ,
1313 Transform ,
14+ config
1415} from '@fortawesome/fontawesome' ;
1516
1617function isIconLookup ( i : IconProp ) : i is IconLookup {
@@ -126,7 +127,19 @@ export class FaIconComponent implements OnChanges {
126127 symbol : this . symbol
127128 } ) ;
128129
129- // @TODO : make sure that it doesn't break things to do html[0] here.
130- this . renderedIconHTML = this . sanitizer . bypassSecurityTrustHtml ( renderedIcon . html [ 0 ] ) ;
130+ let html ;
131+ if ( renderedIcon ) {
132+ html = renderedIcon . html [ 0 ] ;
133+ } else {
134+ html = `<svg class="${ config . replacementClass } " viewBox="0 0 448 512"></svg><!--icon not found-->` ;
135+ if ( iconSpec == null ) {
136+ console . error ( 'Could not find icon. ' +
137+ `It looks like you've provided a null or undefined icon object to this component.` ) ;
138+ } else {
139+ console . error ( `Could not find icon: iconName=${ iconSpec . iconName } , prefix=${ iconSpec . prefix } ` ) ;
140+ }
141+ }
142+
143+ this . renderedIconHTML = this . sanitizer . bypassSecurityTrustHtml ( html ) ;
131144 }
132145}
You can’t perform that action at this time.
0 commit comments