From 17f3c12bf64a79d619c734b0dc9a2c5156067eca Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Wed, 23 Oct 2013 19:17:29 -0400 Subject: [PATCH] make sure that unsetting using set with an object works --- backbone-nested.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backbone-nested.js b/backbone-nested.js index 1ee5d72..bfc9c26 100644 --- a/backbone-nested.js +++ b/backbone-nested.js @@ -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();