-
Notifications
You must be signed in to change notification settings - Fork 308
Description
In ModelStore#set, we determine the cache key based on the type of model. This is done using modelUtils.modelName(model), which in turn looks at the id or name property of model.constructor.
Now, in the case where a collection does not specify a custom model class, it will just use BaseModel. A problem arises when ModelStore#set is called on a model of this collection, because its modelName will be blank (it's an empty string in Chrome, and undefined in IE because IE doesn't support constructor.name). So IE throws an error, and Chrome just uses a bad cache key, i.e. ":14" instead of "my_model:14", in the case where model.id = 14.
Sample collection:
var BaseCollection = require('rendr/shared/base/collection');
module.exports = BaseCollection.extend({});Solution: modelUtils.modelName should fall back to looking at model.collection.constructor.id if model.constructor.id is blank.