A silent change to a model will now make hasChanged() return true ... Issue #105

This commit is contained in:
Jeremy Ashkenas
2010-12-03 09:54:27 -05:00
parent b085fa0099
commit bbcf19684c
2 changed files with 6 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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');
});