From f37f978e2c614d3eb9df001bd059a056ff1b6952 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sun, 7 Jul 2019 15:41:59 +0200 Subject: [PATCH] Fixed problem with fieldsArray: field were being added even if the keys check was failing --- src/fieldsArray.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fieldsArray.js b/src/fieldsArray.js index 68a4dc2..1a90fd0 100644 --- a/src/fieldsArray.js +++ b/src/fieldsArray.js @@ -26,12 +26,12 @@ class FieldsArray extends Array { return acc; } - if (acc.some(e => e.key === current.key) || this[poolSymbol].has(current.key)) { - debug(`Field with key "${key}" discarded: fields must be unique in pass scope.`); - } - - this[poolSymbol].add(current.key) - acc.push(current) + if (this[poolSymbol].has(current.key)) { + debug(`Field with key "${current.key}" discarded: fields must be unique in pass scope.`); + } else { + this[poolSymbol].add(current.key); + acc.push(current); + } return acc; }, []);