Setting _unsetAttributes to false in unset rather than changedAttributes so that the unset attributes aren't lost on subsequent calls of changedAttributes. Added test to verify this behavior.

This commit is contained in:
Irene Ros
2011-10-29 12:27:46 -04:00
parent d50c5e980b
commit 2be771412b
2 changed files with 4 additions and 2 deletions

View File

@@ -253,6 +253,7 @@
if (!options.silent) {
this.trigger('change:' + attr, this, void 0, options);
this.change(options);
this._unsetAttributes = false;
}
return this;
},
@@ -389,7 +390,6 @@
changed[attr] = void 0;
}
this._unsetAttributes = false;
return changed;
},

View File

@@ -175,7 +175,9 @@ $(document).ready(function() {
model.unset('a', {silent: true});
var changedAttributes = model.changedAttributes();
ok('a' in changedAttributes, 'changedAttributes should contain unset properties');
equals(changedAttributes.a, undefined);
changedAttributes = model.changedAttributes();
ok('a' in changedAttributes, 'changedAttributes should contain unset properties when running changedAttributes again after an unset.');
});
test("Model: using a non-default id attribute.", function() {