Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import type {
SubsGets, SubsGetsUpd,
} from '@ts/core/reactive/index';
import { computed, state } from '@ts/core/reactive/index';
import { extend } from '@ts/core/utils/m_extend';
import { isPlainObject } from '@ts/core/utils/m_type';
import type { ComponentType } from 'inferno';

import { TemplateWrapper } from '../inferno_wrappers/template_wrapper';
Expand Down Expand Up @@ -58,13 +60,19 @@ function updateImmutable<T extends Record<string, unknown> | unknown[]>(
const [pathPart, ...restPathParts] = pathParts;
const ret = cloneObjectValue(value);

// eslint-disable-next-line no-nested-ternary
ret[pathPart] = restPathParts.length
? updateImmutable(value[pathPart], newValue[pathPart], restPathParts)
: newValue[pathPart];
: isPlainObject(newValue[pathPart])
? extend(true, {}, newValue[pathPart])
: newValue[pathPart];

return ret;
}

// @ts-expect-error
window.updateImmutable = updateImmutable;

function getValue<T>(obj: unknown, path: string): T {
let v: any = obj;
for (const pathPart of getPathParts(path)) {
Expand Down
Loading