marionettejs / backbone.marionette

The Backbone Framework
https://marionettejs.com
Other
7.07k stars 1.26k forks source link

Error: "Cannot read property 'idAttribute' of undefined" in collection #3627

Closed avasuro closed 6 years ago

avasuro commented 6 years ago

Sorry, just noticed that it's a Backbone bug, so this issue is not relevant to Marionette.


Description

  1. If I create new collection class, that extends Backbone.Collection, and define it's "model" property as a function which returns instantiated model - then on collection constructed error "Cannot read property 'idAttribute' of undefined" is thrown. That's because class methods has no property "prototype", which is used in Backbone.Collection.prototype.modelId method.
  2. Check that prototype exists in model constructor

Expected behavior

No error thrown if collection has property "model" defined as class method.

Actual behavior

Error "Cannot read property 'idAttribute' of undefined" thrown. Here is an example: https://jsfiddle.net/e1ybjmw3/

Environment

  1. Marionette version: 4.0.0
  2. Backbone version: 1.3.3
  3. Additional build tools, etc: no build tools (that's important, because if babel used all works fine)
paulfalgout commented 6 years ago

ayep backbone

paulfalgout commented 6 years ago

I don't think that attribute can be defined as a function