Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Throw an error in DOM Storage if given a bad Storage

  • Loading branch information...
commit 3e189e3344d092688bdecbf42b078457ad53f54a 1 parent 039e56f
@JosephPecoraro JosephPecoraro authored
Showing with 12 additions and 9 deletions.
  1. +12 −9 src/adaptors/DOMStorageAdaptor.js
View
21 src/adaptors/DOMStorageAdaptor.js
@@ -2,22 +2,25 @@
* DOMStorageAdaptor
* ===================
* DOM Storage implementation for Lawnchair.
- *
+ *
*/
var DOMStorageAdaptor = function(options) {
- for (var i in LawnchairAdaptorHelpers) {
- this[i] = LawnchairAdaptorHelpers[i];
- }
- this.init(options);
+ for (var i in LawnchairAdaptorHelpers) {
+ this[i] = LawnchairAdaptorHelpers[i];
+ }
+ this.init(options);
};
DOMStorageAdaptor.prototype = {
- init:function(options) {
- this.storage = this.merge(window.localStorage, options.storage);
- },
+ init:function(options) {
+ this.storage = this.merge(window.localStorage, options.storage);
+
+ if (!(this.storage instanceof window.Storage))
+ throw('Lawnchair, "This browser does not support DOM Storage or provided storage was invalid."');
+ },
- save:function(obj, callback) {
+ save:function(obj, callback) {
var id = obj.key || this.uuid();
delete obj.key;
this.storage.setItem(id, this.serialize(obj));
Please sign in to comment.
Something went wrong with that request. Please try again.