model.collection isn't always there. #47

Closed
sontek opened this Issue Nov 12, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

sontek commented Nov 12, 2012

This line:

var store = model.localStorage || model.collection.localStorage; ( https://github.com/jeromegn/Backbone.localStorage/blob/master/backbone.localStorage.js#L93 )

assumes that model.collection will be there but if you have a model who is not part of a collection, then this wont be there and you'll get cannot read property localStorage of undefined.

Owner

jeromegn commented Jan 14, 2013

Can you write a test case where this happens?

To me this looks fine. If the model is not within a collection, then the second part of the conditional statement will not be evaluated.

@jeromegn jeromegn closed this Jan 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment