2018-03-25 18:03:08 +00:00
|
|
|
// License: LGPL-3.0-or-later
|
2018-03-25 17:30:42 +00:00
|
|
|
module.exports = function (state, ev){
|
|
|
|
var target = ev.target
|
|
|
|
var names = target.name.split('.')
|
|
|
|
var value = target.type === 'checkbox' ? target.checked : target.value
|
|
|
|
var nestedState = state
|
|
|
|
|
|
|
|
for(var i = 0, len = names.length - 1; i < len; ++i) {
|
|
|
|
if(nestedState[names[i]] === undefined) return state
|
|
|
|
nestedState = nestedState[names[i]]
|
|
|
|
}
|
|
|
|
|
|
|
|
var lastKey = names[names.length - 1]
|
|
|
|
|
|
|
|
nestedState[lastKey] = value
|
|
|
|
|
|
|
|
return state
|
|
|
|
}
|