-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Description
This was discussed previously in #2080; however it was discussed in the context of _.bindAll(this)
and I think that confused the discussion, because the issue is not about _.bindAll(this)
at all. It actually happens whenever the model
function lacks a prototype
property. For example:
var myCollection = Backbone.Collection.extend({
initialize: function() {
this.model.prototype = null;
},
model: function(attrs, options) {
return new Backbone.Model(attrs, options);
}
});
new myCollection([{ a: 1 }]);
Backbone errors on this line https://github.com/jashkenas/backbone/blob/master/backbone.js#L939 because prototype
doesn't exist.
Obviously, few people would write this.model.prototype = null
, but a lot of people might write this.model = _.bind(this.model)
, which also removes the prototype. Backbone should be able to handle this case.
It seems like it'd be pretty straightforward to have line 939 also check for the existence of prototype
. What do you think?