mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-24 06:17:55 -05:00
Merging in #167, unsetting 'id'
This commit is contained in:
@@ -215,9 +215,7 @@
|
||||
// Remove the attribute.
|
||||
delete this.attributes[attr];
|
||||
delete this._escapedAttributes[attr];
|
||||
if (attr == 'id') {
|
||||
delete this.id;
|
||||
}
|
||||
if (attr == 'id') delete this.id;
|
||||
this._changed = true;
|
||||
if (!options.silent) {
|
||||
this.trigger('change:' + attr, this, void 0, options);
|
||||
|
||||
@@ -133,7 +133,7 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
test("Model: set and unset", function() {
|
||||
attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
|
||||
attrs = {id: 'id', foo: 1, bar: 2, baz: 3};
|
||||
a = new Backbone.Model(attrs);
|
||||
var changeCount = 0;
|
||||
a.bind("change:foo", function() { changeCount += 1; });
|
||||
@@ -147,6 +147,9 @@ $(document).ready(function() {
|
||||
a.unset('foo');
|
||||
ok(a.get('foo')== null, "Foo should have changed");
|
||||
ok(changeCount == 2, "Change count should have incremented for unset.");
|
||||
|
||||
a.unset('id');
|
||||
equals(a.id, undefined, "Unsetting the id should remove the id property.");
|
||||
});
|
||||
|
||||
test("Model: set an empty string", function() {
|
||||
@@ -322,7 +325,7 @@ $(document).ready(function() {
|
||||
equals(lastError, "Can't change admin status.");
|
||||
equals(boundError, undefined);
|
||||
});
|
||||
|
||||
|
||||
test("Model: Inherit class properties", function() {
|
||||
var Parent = Backbone.Model.extend({
|
||||
instancePropSame: function() {},
|
||||
@@ -333,7 +336,7 @@ $(document).ready(function() {
|
||||
var Child = Parent.extend({
|
||||
instancePropDiff: function() {}
|
||||
});
|
||||
|
||||
|
||||
var adult = new Parent;
|
||||
var kid = new Child;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user