mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
using isEqual to check model change
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user