craftyjs/Crafty — pull request #692 by kevinsimper (2014-01-11 23:33:17+00:00)
Title: New storage based on localStorage

I made a new Crafty.storage function which is based on the localStorage function which is very presence in the browsers we support. http://caniuse.com/namevalue-storage

I choose to make it a single function just as we do with `.attr`.

The object if that is passed is `JSON.stringify` and tried parsed when you try to get it again.

I have not made any function like, `.hasKey`, because you should try to get an value and then deal with the result instead of doing two calls, first `.hasKey` and then after `.storage`. That would make you hit localStorage 2 times instead of just one. Made an example to show how you should do it.

There could be an fallback to cookiesupport, but as seen on the caniuse.com site, localStorage is very supported so i do not think it has to be more complicated than it should.