[Pkg-javascript-commits] [backbone] 05/211: A silent change to a model will now make hasChanged() return true ... Issue #105

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:59:56 UTC 2014


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

js pushed a commit to tag 0.5.0
in repository backbone.

commit bbcf19684c7fb87b78acfbcc33e12217265e08ae
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Fri Dec 3 09:54:27 2010 -0500

    A silent change to a model will now make hasChanged() return true ... Issue #105
---
 backbone.js   | 10 ++++------
 test/model.js |  2 ++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/backbone.js b/backbone.js
index 3031eb1..4217e62 100644
--- a/backbone.js
+++ b/backbone.js
@@ -180,10 +180,8 @@
         if (!_.isEqual(now[attr], val)) {
           now[attr] = val;
           delete escaped[attr];
-          if (!options.silent) {
-            this._changed = true;
-            this.trigger('change:' + attr, this, val, options);
-          }
+          this._changed = true;
+          if (!options.silent) this.trigger('change:' + attr, this, val, options);
         }
       }
 
@@ -206,8 +204,8 @@
       // Remove the attribute.
       delete this.attributes[attr];
       delete this._escapedAttributes[attr];
+      this._changed = true;
       if (!options.silent) {
-        this._changed = true;
         this.trigger('change:' + attr, this, void 0, options);
         this.change(options);
       }
@@ -227,8 +225,8 @@
 
       this.attributes = {};
       this._escapedAttributes = {};
+      this._changed = true;
       if (!options.silent) {
-        this._changed = true;
         for (attr in old) {
           this.trigger('change:' + attr, this, void 0, options);
         }
diff --git a/test/model.js b/test/model.js
index c1dfe3e..87e12e6 100644
--- a/test/model.js
+++ b/test/model.js
@@ -159,6 +159,8 @@ $(document).ready(function() {
       ok(_.isEqual(model.previousAttributes(), {name : "Tim", age : 10}), 'previousAttributes is correct');
     });
     model.set({name : 'Rob'}, {silent : true});
+    equals(model.hasChanged(), true);
+    equals(model.hasChanged('name'), true);
     model.change();
     equals(model.get('name'), 'Rob');
   });

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