From ed0f3aaeac891e8a303e17220d41b79941f45463 Mon Sep 17 00:00:00 2001 From: 1on Date: Mon, 16 Nov 2020 17:42:26 +0300 Subject: [PATCH] fix: fixed removing array item in form data --- src/utils/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index f300cad..aae4878 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -39,6 +39,10 @@ export function setNested (obj: Record, 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, field: string, value: any): subProxy = subProxy[matches[2]] } } else { - if (subProxy === undefined) { - break - } if (i === fieldParts.length - 1) { subProxy[fieldPart] = value break