mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-23 22:08:04 -05:00
Merge branch 'master' of github.com:spmason/backbone
This commit is contained in:
@@ -374,6 +374,12 @@
|
||||
changed[attr] = now[attr];
|
||||
}
|
||||
}
|
||||
for (attr in old){
|
||||
if (!(attr in now)){
|
||||
changed = changed || {};
|
||||
changed[attr] = void 0;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
},
|
||||
|
||||
|
||||
@@ -170,6 +170,14 @@ $(document).ready(function() {
|
||||
equals(i, 2, 'Unset does not fire an event for missing attributes.');
|
||||
});
|
||||
|
||||
test("Model: unset and changedAttributes", function() {
|
||||
var model = new Backbone.Model({a: 1});
|
||||
model.unset('a', {silent: true});
|
||||
var changedAttributes = model.changedAttributes();
|
||||
ok('a' in changedAttributes, 'changedAttributes should contain unset properties');
|
||||
equals(changedAttributes.a, undefined);
|
||||
});
|
||||
|
||||
test("Model: using a non-default id attribute.", function() {
|
||||
var MongoModel = Backbone.Model.extend({idAttribute : '_id'});
|
||||
var model = new MongoModel({id: 'eye-dee', _id: 25, title: 'Model'});
|
||||
|
||||
Reference in New Issue
Block a user