1
0
mirror of synced 2024-11-22 05:16:05 +03:00

fix: fixed removing array item in form data

This commit is contained in:
1on 2020-11-16 17:42:26 +03:00
parent 6115322699
commit ed0f3aaeac

View File

@ -39,6 +39,10 @@ export function setNested (obj: Record<string, any>, field: string, value: any):
const fieldPart = fieldParts[i]
const matches = fieldPart.match(/(.+)\[(\d+)\]$/)
if (subProxy === undefined) {
break
}
if (matches) {
if (subProxy[matches[1]] === undefined) {
subProxy[matches[1]] = []
@ -52,9 +56,6 @@ export function setNested (obj: Record<string, any>, field: string, value: any):
subProxy = subProxy[matches[2]]
}
} else {
if (subProxy === undefined) {
break
}
if (i === fieldParts.length - 1) {
subProxy[fieldPart] = value
break