1
0
mirror of synced 2024-11-25 14:56:03 +03:00

Merge pull request #18 from 1on/dev

fix: fixed removing array item in form data
This commit is contained in:
Kruglov Kirill 2020-11-17 09:34:02 +03:00 committed by GitHub
commit 91b928f144
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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