Fix add in array reusing existing element as oldValue

This commit is contained in:
jos 2018-09-05 12:10:49 +02:00
parent e2ffd04e6e
commit 9b2b8233af
1 changed files with 3 additions and 1 deletions

View File

@ -166,7 +166,9 @@ export function add (json, path, value, options) {
const resolvedPath = resolvePathIndex(json, path)
const parent = getIn(json, initial(path))
const parentIsArray = Array.isArray(parent)
const oldValue = getIn(json, resolvedPath)
const oldValue = parentIsArray
? undefined
: getIn(json, resolvedPath)
const newValue = options.fromJSON(value, oldValue)
const updatedJson = parentIsArray