@@ -40,14 +40,20 @@ export function resolveInstanceKey(instance: any, key: string): { root: any; tar
40
40
if ( ! key . includes ( '.' ) ) return { root : instance , targetKey : key , targetProp } ;
41
41
42
42
// Resolve pierced target
43
- const chain = key . split ( '.' ) ;
44
- targetProp = chain . reduce ( ( acc , part ) => acc [ part ] , instance ) ;
45
- const targetKey = chain . pop ( ) ! ;
46
-
47
- // Switch root if atomic
48
- if ( ! targetProp ?. set ) instance = chain . reduce ( ( acc , part ) => acc [ part ] , instance ) ;
49
-
50
- return { root : instance , targetKey, targetProp } ;
43
+ targetProp = instance ;
44
+ for ( const part of key . split ( '.' ) ) {
45
+ key = part ;
46
+ instance = targetProp ;
47
+ targetProp = targetProp [ key ] ;
48
+ }
49
+ // const chain = key.split('.');
50
+ // targetProp = chain.reduce((acc, part) => acc[part], instance);
51
+ // const targetKey = chain.pop()!;
52
+ //
53
+ // // Switch root if atomic
54
+ // if (!targetProp?.set) instance = chain.reduce((acc, part) => acc[part], instance);
55
+
56
+ return { root : instance , targetKey : key , targetProp } ;
51
57
}
52
58
53
59
// This function applies a set of changes to the instance
0 commit comments