mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Merge pull request #1896 from braddunbar/push-sort
Fix #1894, Collection#push should not sort.
This commit is contained in:
@@ -730,7 +730,7 @@
|
||||
// Add a model to the end of the collection.
|
||||
push: function(model, options) {
|
||||
model = this._prepareModel(model, options);
|
||||
this.add(model, options);
|
||||
this.add(model, _.extend({at: this.length}, options));
|
||||
return model;
|
||||
},
|
||||
|
||||
|
||||
@@ -828,4 +828,14 @@ $(document).ready(function() {
|
||||
strictEqual(c.length, 0);
|
||||
});
|
||||
|
||||
test("#1894 - Push should not trigger a sort", 0, function() {
|
||||
var Collection = Backbone.Collection.extend({
|
||||
comparator: 'id',
|
||||
sort: function() {
|
||||
ok(false);
|
||||
}
|
||||
});
|
||||
new Collection().push({id: 1});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user