Skip to content

Commit

Permalink
make sure that unsetting using set with an object works
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev committed Oct 23, 2013
1 parent 72a4a6a commit 17f3c12
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backbone-nested.js
Expand Up @@ -75,13 +75,17 @@
unsetObj[key] = null;
Backbone.NestedModel.__super__.set.call(this, unsetObj, opts);
} else {
var unsetObj = newAttrs;

// normal set(), or an unset of nested attribute
if (opts.unset && attrPath){
// make sure Backbone.Model won't unset the top-level attribute
opts = _.extend({}, opts);
delete opts.unset;
} else if (opts.unset && _.isObject(key)) {
unsetObj = key;
}
Backbone.NestedModel.__super__.set.call(this, newAttrs, opts);
Backbone.NestedModel.__super__.set.call(this, unsetObj, opts);
}

this._runDelayedTriggers();
Expand Down

0 comments on commit 17f3c12

Please sign in to comment.