Skip to content

Commit

Permalink
Check if session data array is for checkboxes
Browse files Browse the repository at this point in the history
As reported in
#693
the session data can get overwritten. This happened if
there is an array in the session data as the logic takes
this to be checkboxes data and stores it, overwriting
the existing data.
  • Loading branch information
hannalaakso committed Mar 11, 2019
1 parent 9e9a581 commit 664985e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,8 @@ var storeData = function (input, data) {
}

// Remove _unchecked from arrays of checkboxes
if (Array.isArray(val)) {
var index = val.indexOf('_unchecked')
if (index !== -1) {
val.splice(index, 1)
}
if (Array.isArray(val) && val.indexOf('_unchecked') !== -1) {
val.splice(val.indexOf('_unchecked'), 1)
} else if (typeof val === 'object') {
// Store nested objects that aren't arrays
if (typeof data[i] !== 'object') {
Expand Down

0 comments on commit 664985e

Please sign in to comment.