Permalink
Browse files

Merge pull request #1944 from tgriesser/isEqualChange

Fix #1943 - use _.isEqual to check model change
  • Loading branch information...
2 parents 8a4af72 + bb67b6c commit c1a9384e9cc4b0fa73e0b956959ca0d8a27ebdee @jashkenas jashkenas committed Dec 14, 2012
Showing with 7 additions and 2 deletions.
  1. +1 −1 backbone.js
  2. +6 −1 test/model.js
View
@@ -539,7 +539,7 @@
// Check if the attribute has been modified since the last change,
// and update `this.changed` accordingly. If we're inside of a `change`
// call, also add a trigger to the list.
- if (current[key] !== val) {
+ if (!_.isEqual(current[key], val)) {
this.changed[key] = val;
if (!loud) continue;
triggers.push(key, val);
View
@@ -326,7 +326,6 @@ $(document).ready(function() {
equal(model.hasChanged('name'), true);
model.change();
equal(model.get('name'), 'Rob');
-
});
test("changedAttributes", 3, function() {
@@ -944,4 +943,10 @@ $(document).ready(function() {
deepEqual(changes, ['a']);
});
+ test("#1943 change calculations should use _.isEqual", function() {
+ var model = new Backbone.Model({a: {key: 'value'}});
+ model.set('a', {key:'value'}, {silent:true});
+ equal(model.changedAttributes(), false);
+ });
+
});

0 comments on commit c1a9384

Please sign in to comment.