0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 02:14:39 +00:00

Fixing a distributing problem

This commit is contained in:
Scott Tolksdorf
2016-04-05 23:07:29 -04:00
parent cb5b63429e
commit 62b9400df1
6 changed files with 27 additions and 20 deletions

View File

@@ -16,14 +16,18 @@ module.exports = {
updateData : function(val){
if(typeof this.props.onChange !== 'function') throw "No onChange handler set";
if(_.isObject(val)){
var newVal = val;
//Clone the data if it's an object to avoid mutation bugs
if(_.isObject(val)) newVal = _.extend({}, this.data(), val);
if(this.id()){
this.props.onChange({
[this.id()] : _.extend({}, this.data(), val)
[this.id()] : newVal
});
}else{
this.props.onChange({
[this.id()] : val
});
//If the box has no id, don't add it to the chain
this.props.onChange(newVal)
}
}
}