@@ -46,6 +46,18 @@ export function parseBindingString(id: string) {
4646 return { parts, signals } ;
4747}
4848
49+ export function getNestedProperty ( obj , path ) {
50+ const parts = path . split ( '.' ) ;
51+ let current = obj ;
52+
53+ for ( const part of parts ) {
54+ if ( current == null || typeof current !== 'object' ) return undefined ;
55+ current = current [ part ] ;
56+ }
57+
58+ return current ;
59+ }
60+
4961class IndirectSignal {
5062 private parts : string [ ] ;
5163 private signals : string [ ] ;
@@ -70,29 +82,48 @@ class IndirectSignal {
7082 let nm = this . signals [ i ] ;
7183 if ( nm [ 0 ] === '?' && nm [ 1 ] === '?' ) {
7284 const propNm = nm . substring ( 2 ) ;
85+ if ( ! propNm . includes ( '.' ) ) {
7386 this . handleValueChanged ( root [ propNm ] , i ) ;
7487
7588 const evtCallback = ( ) => this . handleValueChanged ( root [ propNm ] , i ) ;
7689 const evtName = bindingsHelper . getChangedEventName ( root , propNm ) ;
7790 root . addEventListener ( evtName , ( evtCallback ) ) ;
7891 this . cleanupCalls . push ( ( ) => root . removeEventListener ( evtName , evtCallback ) ) ;
92+ } else {
93+ const val = getNestedProperty ( root , propNm ) ;
94+ this . handleValueChanged ( val , i ) ;
95+ }
7996 continue ;
8097 }
8198 else if ( nm [ 0 ] === '#' && nm [ 1 ] === '#' ) {
99+ } else if ( nm [ 0 ] === '#' && nm [ 1 ] === '#' ) {
82100 const propNm = nm . substring ( 2 ) ;
101+ if ( ! propNm . includes ( '.' ) ) {
83102 this . handleValueChanged ( element [ propNm ] , i ) ;
84103
85104 const evtCallback = ( ) => this . handleValueChanged ( element [ propNm ] , i ) ;
86105 const evtName = bindingsHelper . getChangedEventName ( element , propNm ) ;
87106 element . addEventListener ( evtName , ( evtCallback ) ) ;
88107 this . cleanupCalls . push ( ( ) => element . removeEventListener ( evtName , evtCallback ) ) ;
108+ } else {
109+ const val = getNestedProperty ( element , propNm ) ;
110+ this . handleValueChanged ( val , i ) ;
111+ }
89112 continue ;
90113 } else if ( nm [ 0 ] === '?' ) {
91114 //TODO: react to changes of signal name in prop
115+ if ( ! nm . includes ( '.' ) ) {
92116 nm = root [ nm . substring ( 1 ) ] ;
117+ } else {
118+ nm = getNestedProperty ( root , nm . substring ( 1 ) ) ;
119+ }
93120 } else if ( nm [ 0 ] === '#' ) {
94121 //TODO: react to changes of signal name in prop
95- nm = element [ nm . substring ( 1 ) ] ;
122+ if ( ! nm . includes ( '.' ) ) {
123+ nm = root [ nm . substring ( 1 ) ] ;
124+ } else {
125+ nm = getNestedProperty ( root , nm . substring ( 1 ) ) ;
126+ }
96127 }
97128
98129 let cb = ( id : string , value : any ) => this . handleValueChanged ( value . val , i ) ;
0 commit comments