[Pkg-javascript-commits] [backbone] 74/281: set _changing = false only if !alreadyChanging

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:01:58 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 20a2e3408a9f8a09c8db6fa3ffb05b47766f5112
Author: Brad Dunbar <dunbarb2 at gmail.com>
Date:   Wed Nov 9 13:56:43 2011 -0500

    set _changing = false only if !alreadyChanging
---
 backbone.js   | 6 ++++--
 test/model.js | 9 +++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/backbone.js b/backbone.js
index eab2e7a..d5b0144 100644
--- a/backbone.js
+++ b/backbone.js
@@ -211,8 +211,10 @@
       }
 
       // Fire the `"change"` event, if the model has been changed.
-      if (!alreadyChanging && !options.silent && this._changed) this.change(options);
-      this._changing = false;
+      if (!alreadyChanging) {
+        if (!options.silent && this._changed) this.change(options);
+        this._changing = false;
+      }
       return this;
     },
 
diff --git a/test/model.js b/test/model.js
index c76e389..4963248 100644
--- a/test/model.js
+++ b/test/model.js
@@ -449,4 +449,13 @@ $(document).ready(function() {
     a.set({state: 'hello'});
   });
 
+  test("Model: Multiple nested calls to set", function() {
+    var model = new Backbone.Model({});
+    model.bind('change', function() {
+      model.set({b: 1});
+      model.set({a: 1});
+    })
+    .set({a: 1});
+  });
+
 });

-- 
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