Merge option for Collection.set is not working in a specific case
When adding models to a collection, duplicates are not merged when Collection.model is defined as a method that instantiates an appropriate model (for polymorphic collections). This happens when the models being added are still defined as objects, not instantiated models.
A minimum example: http://jsfiddle.net/tkriplean/xLQHf/3/
The issue occurs in Collection.set on line 683 (for v1.1.0):
id = attrs[targetModel.prototype.idAttribute];
In the case described, targetModel will be a method, not a model class, and therefore targetModel.prototype.idAttribute is always undefined. Which subsequently means that the already existing model is never found.
An ugly workaround is to instantiate the list of models first and then add them to the target collection.
Anyway, just wanted to report this issue :-)
Thanks for Backbone, it is great!
Thanks @j03w I tried out the master branch and it is indeed fixed there. Sorry for the redundant issue.