@@ -8,7 +8,8 @@ import { transformName } from './icon.utils';
8
8
@Directive ( {
9
9
exportAs : 'cIcon' ,
10
10
selector : 'svg[cIcon]' ,
11
- standalone : true
11
+ standalone : true ,
12
+ host : { ngSkipHydration : 'true' , '[innerHtml]' : 'innerHtml()' }
12
13
} )
13
14
export class IconDirective implements IIcon {
14
15
readonly #elementRef = inject ( ElementRef ) ;
@@ -78,13 +79,8 @@ export class IconDirective implements IIcon {
78
79
return this . computedClasses ;
79
80
}
80
81
81
- @HostBinding ( 'innerHtml' )
82
- get bindInnerHtml ( ) {
83
- return this . innerHtml ( ) ;
84
- }
85
-
86
82
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 ( ) || '' ;
88
84
// todo proper sanitize
89
85
// const sanitized = this.sanitizer.sanitize(SecurityContext.HTML, code);
90
86
return this . #sanitizer. bypassSecurityTrustHtml ( this . titleCode + code || '' ) ;
@@ -103,16 +99,15 @@ export class IconDirective implements IIcon {
103
99
}
104
100
if ( this . #name( ) && ! this . #iconSet?. icons [ this . #name( ) ] ) {
105
101
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` ,
108
103
this . #name( )
109
104
) ;
110
105
}
111
106
return '' ;
112
107
} ) ;
113
108
114
109
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' ;
116
111
} ) ;
117
112
118
113
get computedSize ( ) : Exclude < IconSize , 'custom' > | undefined {
0 commit comments