@@ -15,7 +15,13 @@ import { NgtArgs } from '../directives/args';
15
15
import { NgtCommonDirective } from '../directives/common' ;
16
16
import { NgtParent } from '../directives/parent' ;
17
17
import { getInstanceState , prepare } from '../instance' ;
18
- import { NgtConstructorRepresentation , NgtEventHandlers , NgtInstanceNode , NgtInstanceState } from '../types' ;
18
+ import {
19
+ NgtAttachable ,
20
+ NgtConstructorRepresentation ,
21
+ NgtEventHandlers ,
22
+ NgtInstanceNode ,
23
+ NgtInstanceState ,
24
+ } from '../types' ;
19
25
import { applyProps } from '../utils/apply-props' ;
20
26
import { is } from '../utils/is' ;
21
27
import { injectCatalogue } from './catalogue' ;
@@ -595,18 +601,8 @@ export class NgtRenderer2 implements Renderer2 {
595
601
596
602
// [attach]
597
603
if ( name === 'attach' ) {
598
- if ( instanceState )
599
- instanceState . attach = Array . isArray ( value )
600
- ? value . map ( ( v ) => v . toString ( ) )
601
- : typeof value === 'function'
602
- ? value
603
- : typeof value === 'string'
604
- ? value . split ( '.' )
605
- : [ value ] ;
606
- if ( parent ) {
607
- untracked ( ( ) => attachThreeNodes ( parent , el as unknown as NgtInstanceNode ) ) ;
608
- }
609
-
604
+ if ( instanceState ) instanceState . attach = this . normalizeAttach ( value ) ;
605
+ if ( parent ) untracked ( ( ) => attachThreeNodes ( parent , el as unknown as NgtInstanceNode ) ) ;
610
606
return ;
611
607
}
612
608
@@ -761,6 +757,12 @@ export class NgtRenderer2 implements Renderer2 {
761
757
return directiveInstance ;
762
758
}
763
759
760
+ private normalizeAttach ( attach : NgtAttachable ) {
761
+ if ( typeof attach === 'function' ) return attach ;
762
+ if ( typeof attach === 'string' ) return attach . split ( '.' ) ;
763
+ return attach . flatMap ( ( item ) => item . toString ( ) . split ( '.' ) ) ;
764
+ }
765
+
764
766
addClass = this . delegateRenderer . addClass . bind ( this . delegateRenderer ) ;
765
767
removeClass = this . delegateRenderer . removeClass . bind ( this . delegateRenderer ) ;
766
768
setStyle = this . delegateRenderer . setStyle . bind ( this . delegateRenderer ) ;
0 commit comments