mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Add a test and tweak whitespace for #1448.
This commit is contained in:
@@ -624,7 +624,6 @@
|
||||
this.length += length;
|
||||
index = options.at != null ? options.at : this.models.length;
|
||||
splice.apply(this.models, [index, 0].concat(models));
|
||||
|
||||
|
||||
// Merge in duplicate models.
|
||||
if (options.merge) {
|
||||
@@ -634,7 +633,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.comparator && options.at == null) this.sort({silent: true});
|
||||
|
||||
// Sort the collection if appropriate.
|
||||
if (this.comparator && options.at == null) this.sort({silent: true});
|
||||
|
||||
if (options.silent) return this;
|
||||
for (i = 0, length = this.models.length; i < length; i++) {
|
||||
|
||||
@@ -656,4 +656,14 @@ $(document).ready(function() {
|
||||
collection.on('add', function(){ ok(true); });
|
||||
collection.create(model, {wait: true});
|
||||
});
|
||||
|
||||
test("#1448 - add sorts collection after merge.", function() {
|
||||
var collection = new Backbone.Collection([
|
||||
{id: 1, x: 1},
|
||||
{id: 2, x: 2}
|
||||
]);
|
||||
collection.comparator = function(model){ return model.get('x'); };
|
||||
collection.add({id: 1, x: 3}, {merge: true});
|
||||
deepEqual(collection.pluck('id'), [2, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user