[Pkg-javascript-commits] [backbone] 37/281: 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.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:01:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.9.0
in repository backbone.

commit 2be771412b8aca39269b59778da259fd2fd16daf
Author: Irene Ros <irene at bocoup.com>
Date:   Sat Oct 29 12:27:46 2011 -0400

    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 190cb06..a4fd089 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 bfb499e..76dc4b0 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() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list