@@ -8,7 +8,8 @@ import { transformName } from './icon.utils';
88@Directive ( {
99 exportAs : 'cIcon' ,
1010 selector : 'svg[cIcon]' ,
11- standalone : true
11+ standalone : true ,
12+ host : { ngSkipHydration : 'true' , '[innerHtml]' : 'innerHtml()' }
1213} )
1314export class IconDirective implements IIcon {
1415 readonly #elementRef = inject ( ElementRef ) ;
@@ -78,13 +79,8 @@ export class IconDirective implements IIcon {
7879 return this . computedClasses ;
7980 }
8081
81- @HostBinding ( 'innerHtml' )
82- get bindInnerHtml ( ) {
83- return this . innerHtml ( ) ;
84- }
85-
8682 readonly innerHtml = computed ( ( ) => {
87- const code = Array . isArray ( this . code ( ) ) ? this . code ( ) [ 1 ] ?? this . code ( ) [ 0 ] ?? '' : this . code ( ) || '' ;
83+ const code = Array . isArray ( this . code ( ) ) ? ( this . code ( ) [ 1 ] ?? this . code ( ) [ 0 ] ?? '' ) : this . code ( ) || '' ;
8884 // todo proper sanitize
8985 // const sanitized = this.sanitizer.sanitize(SecurityContext.HTML, code);
9086 return this . #sanitizer. bypassSecurityTrustHtml ( this . titleCode + code || '' ) ;
@@ -103,16 +99,15 @@ export class IconDirective implements IIcon {
10399 }
104100 if ( this . #name( ) && ! this . #iconSet?. icons [ this . #name( ) ] ) {
105101 console . warn (
106- `c-icon component: icon name '${ this . #name( ) } ' does not exist for IconSet service. ` +
107- `To use icon by 'name' prop you need to add it to IconSet service. \n` ,
102+ `cIcon directive: The '${ this . #name( ) } ' icon not found. Add it to the IconSet service for use with the 'name' property. \n` ,
108103 this . #name( )
109104 ) ;
110105 }
111106 return '' ;
112107 } ) ;
113108
114109 readonly scale = computed ( ( ) => {
115- return Array . isArray ( this . code ( ) ) && this . code ( ) . length > 1 ? `0 0 ${ this . code ( ) [ 0 ] } ` : '0 0 64 64' ;
110+ return Array . isArray ( this . code ( ) ) && ( this . code ( ) ? .length ?? 0 ) > 1 ? `0 0 ${ this . code ( ) ?. [ 0 ] } ` : '0 0 64 64' ;
116111 } ) ;
117112
118113 get computedSize ( ) : Exclude < IconSize , 'custom' > | undefined {
0 commit comments