using isEqual to check model change

This commit is contained in:
Tim Griesser
2012-12-14 15:04:16 -05:00
parent b7102e0a61
commit bb67b6c60d
2 changed files with 7 additions and 2 deletions

View File

@@ -548,7 +548,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 File

@@ -314,7 +314,6 @@ $(document).ready(function() {
equal(model.hasChanged('name'), true);
model.change();
equal(model.get('name'), 'Rob');
});
test("changedAttributes", 3, function() {
@@ -948,4 +947,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);
});
});