@@ -4,22 +4,28 @@ import { NgtAnyRecord } from '../types';
4
4
import { applyProps } from './apply-props' ;
5
5
import { NgtSignalStore } from './signal-store' ;
6
6
7
- export function attach ( object : NgtAnyRecord , value : unknown , paths : string [ ] = [ ] ) : void {
7
+ export function attach ( object : NgtAnyRecord , value : unknown , paths : string [ ] = [ ] , useApplyProps = false ) : void {
8
8
const [ base , ...remaining ] = paths ;
9
9
if ( ! base ) return ;
10
10
11
11
if ( remaining . length === 0 ) {
12
- applyProps ( object , { [ base ] : value } ) ;
12
+ if ( useApplyProps ) applyProps ( object , { [ base ] : value } ) ;
13
+ else object [ base ] = value ;
13
14
} else {
14
15
assignEmpty ( object , base ) ;
15
- attach ( object [ base ] , value , remaining ) ;
16
+ attach ( object [ base ] , value , remaining , useApplyProps ) ;
16
17
}
17
18
}
18
19
19
- export function detach ( parent : NgtAnyRecord , child : NgtAnyRecord , attachProp : string [ ] | NgtAttachFunction ) {
20
+ export function detach (
21
+ parent : NgtAnyRecord ,
22
+ child : NgtAnyRecord ,
23
+ attachProp : string [ ] | NgtAttachFunction ,
24
+ useApplyProps = false ,
25
+ ) {
20
26
const childLocalState = getLocalState ( child ) ;
21
27
if ( childLocalState ) {
22
- if ( Array . isArray ( attachProp ) ) attach ( parent , childLocalState . previousAttach , attachProp ) ;
28
+ if ( Array . isArray ( attachProp ) ) attach ( parent , childLocalState . previousAttach , attachProp , childLocalState . isRaw ) ;
23
29
else ( childLocalState . previousAttach as ( ) => void ) ( ) ;
24
30
}
25
31
}
0 commit comments