* Perform a modification to a single element of a parent aggregate value. This * is only performed on the pre-committed value (_value), although typically * the value and _value are both linked in memory. * * @param context - A FormKitContext | FormKitContext * * @internal
(
context: FormKitContext,
{ name, value, from }: FormKitChildValue
)
| 1966 | * @internal |
| 1967 | */ |
| 1968 | function partial( |
| 1969 | context: FormKitContext, |
| 1970 | { name, value, from }: FormKitChildValue |
| 1971 | ) { |
| 1972 | if (Object.isFrozen(context._value)) return |
| 1973 | if (isList(context)) { |
| 1974 | const insert: any[] = |
| 1975 | value === valueRemoved |
| 1976 | ? [] |
| 1977 | : value === valueMoved && typeof from === 'number' |
| 1978 | ? context._value.splice(from, 1) |
| 1979 | : [value] |
| 1980 | context._value.splice( |
| 1981 | name as number, |
| 1982 | value === valueMoved || from === valueInserted ? 0 : 1, |
| 1983 | ...insert |
| 1984 | ) |
| 1985 | return |
| 1986 | } |
| 1987 | |
| 1988 | if (value !== valueRemoved) { |
| 1989 | ;(context._value as FormKitGroupValue)[name as string] = value |
| 1990 | } else { |
| 1991 | delete (context._value as FormKitGroupValue)[name as string] |
| 1992 | } |
| 1993 | } |
| 1994 | |
| 1995 | /** |
| 1996 | * Hydrate node and its children |