Comments (6)
confirming this is a bug as well.
from backbone.localstorage.
Same here. Fix from Sergeyshall resolved the issue for me.
from backbone.localstorage.
Wow, I have no been receiving the email notifications of new issues. I'm sorry if that took a while.
Would you mind submitting a pull request with that code? Maybe even write a test for it :)
from backbone.localstorage.
My two cents - I've come across this problem before too, but my suggested approach would be to duck-punch JSON.parse. This way we don't need to add the same null checks every time we are parsing JSON. Pull Request #41 only fixes the case of JSON.parse within this library - what if I need to do JSON.parse in my own code?
For example:
brianleroux/lawnchair#48 (comment)
from backbone.localstorage.
We've come across this issue as well. In our own code it's trivial to implement a null check like value && JSON.parse(value);
. To keep the fixing code separate we added jsonData()
.
find: function(model) {
// call to this.jsonData instead of JSON.parse
return this.jsonData(this.localStorage().getItem(this.name+"-"+model.id));
}
findAll: function() {
return _(this.records).chain()
.map(function(id){
return this.jsonData(this.localStorage().getItem(this.name+"-"+id));
}, this)
.compact()
.value();
}
and as above the actual handling is simple
jsonData: function (data) {
return data && JSON.parse(data);
}
from backbone.localstorage.
@nerdgore If you'd like to submit that as a pull request, it'd be greatly appreciated.
from backbone.localstorage.
Related Issues (20)
- Regex error on _clear method
- require config localstorage makes 'Load timeout for modules' error HOT 1
- Duplicate values in records when calling create method multiple times HOT 1
- how to fetch collection from localstorage ?? HOT 9
- Rename to BackboneStorage HOT 1
- Multi-page for local data is empty HOT 1
- underscore.js HOT 1
- Signatures for success() and error() not (model, resp, options)
- Doesn't work with Browserify HOT 2
- Maintaining LocalStorage HOT 4
- Remove Unmaintained Description HOT 2
- Wrong path for main in package.json HOT 1
- Disable console.log in LocalStorage HOT 1
- Webpack required to build usable bacbone.localstorage.js file in browser? HOT 4
- Loading Backbone LocalStorage with requirejs returns an error HOT 5
- Models not saving correctly under version 2.0.0 HOT 3
- Unable to get property 'collection' of undefined or null reference when calling sync(); HOT 1
- Bug in "destroy" metod of localStorage.js HOT 2
- Delete a model from local storage HOT 1
- findAll() returns array and breaks model.fetch()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backbone.localstorage.