From 2be771412b8aca39269b59778da259fd2fd16daf Mon Sep 17 00:00:00 2001 From: Irene Ros Date: Sat, 29 Oct 2011 12:27:46 -0400 Subject: [PATCH] Setting _unsetAttributes to false in unset rather than changedAttributes so that the unset attributes aren't lost on subsequent calls of changedAttributes. Added test to verify this behavior. --- backbone.js | 2 +- test/model.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backbone.js b/backbone.js index 190cb06a..a4fd089c 100644 --- a/backbone.js +++ b/backbone.js @@ -253,6 +253,7 @@ if (!options.silent) { this.trigger('change:' + attr, this, void 0, options); this.change(options); + this._unsetAttributes = false; } return this; }, @@ -389,7 +390,6 @@ changed[attr] = void 0; } - this._unsetAttributes = false; return changed; }, diff --git a/test/model.js b/test/model.js index bfb499ea..76dc4b0b 100644 --- a/test/model.js +++ b/test/model.js @@ -175,7 +175,9 @@ $(document).ready(function() { model.unset('a', {silent: true}); var changedAttributes = model.changedAttributes(); ok('a' in changedAttributes, 'changedAttributes should contain unset properties'); - equals(changedAttributes.a, undefined); + + changedAttributes = model.changedAttributes(); + ok('a' in changedAttributes, 'changedAttributes should contain unset properties when running changedAttributes again after an unset.'); }); test("Model: using a non-default id attribute.", function() {