@@ -15,7 +15,13 @@ import { NgtArgs } from '../directives/args';
1515import { NgtCommonDirective } from '../directives/common' ;
1616import { NgtParent } from '../directives/parent' ;
1717import { 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' ;
1925import { applyProps } from '../utils/apply-props' ;
2026import { is } from '../utils/is' ;
2127import { injectCatalogue } from './catalogue' ;
@@ -595,18 +601,8 @@ export class NgtRenderer2 implements Renderer2 {
595601
596602 // [attach]
597603 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 ) ) ;
610606 return ;
611607 }
612608
@@ -761,6 +757,12 @@ export class NgtRenderer2 implements Renderer2 {
761757 return directiveInstance ;
762758 }
763759
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+
764766 addClass = this . delegateRenderer . addClass . bind ( this . delegateRenderer ) ;
765767 removeClass = this . delegateRenderer . removeClass . bind ( this . delegateRenderer ) ;
766768 setStyle = this . delegateRenderer . setStyle . bind ( this . delegateRenderer ) ;
0 commit comments