Skip to content

Commit b247f95

Browse files
committed
adjust attach to use applyProps with a flag instead of always
1 parent d10655e commit b247f95

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

libs/core/src/lib/renderer/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,10 @@ export class NgtRenderer implements Renderer2 {
360360
maybeCoerced = Number(maybeCoerced);
361361
}
362362
rS[NgtRendererClassId.rawValue] = maybeCoerced;
363+
} else {
364+
applyProps(el, { [name]: value });
363365
}
364366

365-
applyProps(el, { [name]: value });
366367
return false;
367368
}
368369

libs/core/src/lib/renderer/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function attachThreeChild(parent: NgtInstanceNode, child: NgtInstanceNode
9595
}
9696
// at this point we don't have rawValue yet, so we bail and wait until the Renderer recalls attach
9797
if (child.__ngt_renderer__[NgtRendererClassId.rawValue] === undefined) return;
98-
attach(parent, child.__ngt_renderer__[NgtRendererClassId.rawValue], attachProp);
98+
attach(parent, child.__ngt_renderer__[NgtRendererClassId.rawValue], attachProp, true);
9999
} else {
100100
attach(parent, child, attachProp);
101101
}

libs/core/src/lib/utils/attach.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,28 @@ import { NgtAnyRecord } from '../types';
44
import { applyProps } from './apply-props';
55
import { NgtSignalStore } from './signal-store';
66

7-
export function attach(object: NgtAnyRecord, value: unknown, paths: string[] = []): void {
7+
export function attach(object: NgtAnyRecord, value: unknown, paths: string[] = [], useApplyProps = false): void {
88
const [base, ...remaining] = paths;
99
if (!base) return;
1010

1111
if (remaining.length === 0) {
12-
applyProps(object, { [base]: value });
12+
if (useApplyProps) applyProps(object, { [base]: value });
13+
else object[base] = value;
1314
} else {
1415
assignEmpty(object, base);
15-
attach(object[base], value, remaining);
16+
attach(object[base], value, remaining, useApplyProps);
1617
}
1718
}
1819

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+
) {
2026
const childLocalState = getLocalState(child);
2127
if (childLocalState) {
22-
if (Array.isArray(attachProp)) attach(parent, childLocalState.previousAttach, attachProp);
28+
if (Array.isArray(attachProp)) attach(parent, childLocalState.previousAttach, attachProp, childLocalState.isRaw);
2329
else (childLocalState.previousAttach as () => void)();
2430
}
2531
}

0 commit comments

Comments
 (0)