Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save orendon/408f18e5838d6b31a0f1 to your computer and use it in GitHub Desktop.
Save orendon/408f18e5838d6b31a0f1 to your computer and use it in GitHub Desktop.

Revisions

  1. orendon renamed this gist May 22, 2014. 1 changed file with 0 additions and 0 deletions.
  2. orendon revised this gist May 22, 2014. 1 changed file with 1 addition and 6 deletions.
    7 changes: 1 addition & 6 deletions best-localStorage-polyfill-evar.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,4 @@
    // I mean, seriously, localStorage is supported even by your mum. How about instead of
    // casing the feature out, you give users in-memory (stale) storage instead?
    // If they close your application, they deserve to lose data anyway.

    // if (!('localStorage' in window)) {
    if (!Modernizr.localstorage) {
    if (!('localStorage' in window)) {
    window.localStorage = {
    _data : {},
    setItem : function(id, val) { return this._data[id] = String(val); },
  3. @juliocesar juliocesar revised this gist Apr 19, 2011. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions best-localStorage-polyfill-evar.js
    Original file line number Diff line number Diff line change
    @@ -4,11 +4,10 @@

    // if (!('localStorage' in window)) {
    if (!Modernizr.localstorage) {
    var undef;
    window.localStorage = {
    _data : {},
    setItem : function(id, val) { return this._data[id] = String(val); },
    getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undef; },
    getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
    removeItem : function(id) { return delete this._data[id]; },
    clear : function() { return this._data = {}; }
    };
  4. @juliocesar juliocesar revised this gist Apr 18, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion best-localStorage-polyfill-evar.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ if (!Modernizr.localstorage) {
    window.localStorage = {
    _data : {},
    setItem : function(id, val) { return this._data[id] = String(val); },
    getItem : function(id) { return data.hasOwnProperty(id) ? data[id] : undef; },
    getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undef; },
    removeItem : function(id) { return delete this._data[id]; },
    clear : function() { return this._data = {}; }
    };
  5. @juliocesar juliocesar revised this gist Apr 18, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions best-localStorage-polyfill-evar.js
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@

    // if (!('localStorage' in window)) {
    if (!Modernizr.localstorage) {
    var undef;
    window.localStorage = {
    _data : {},
    setItem : function(id, val) { return this._data[id] = String(val); },
  6. @juliocesar juliocesar revised this gist Apr 18, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion best-localStorage-polyfill-evar.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ if (!Modernizr.localstorage) {
    window.localStorage = {
    _data : {},
    setItem : function(id, val) { return this._data[id] = String(val); },
    getItem : function(id) { return this._data[id]; },
    getItem : function(id) { return data.hasOwnProperty(id) ? data[id] : undef; },
    removeItem : function(id) { return delete this._data[id]; },
    clear : function() { return this._data = {}; }
    };
  7. @juliocesar juliocesar revised this gist Apr 18, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion best-localStorage-polyfill-evar.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    if (!Modernizr.localstorage) {
    window.localStorage = {
    _data : {},
    setItem : function(id, val) { return this._data[id] = val; },
    setItem : function(id, val) { return this._data[id] = String(val); },
    getItem : function(id) { return this._data[id]; },
    removeItem : function(id) { return delete this._data[id]; },
    clear : function() { return this._data = {}; }
  8. @juliocesar juliocesar revised this gist Apr 18, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions best-localStorage-polyfill-evar.js
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@
    // casing the feature out, you give users in-memory (stale) storage instead?
    // If they close your application, they deserve to lose data anyway.

    // if (!('localStorage' in window)) {
    if (!Modernizr.localstorage) {
    window.localStorage = {
    _data : {},
  9. @juliocesar juliocesar created this gist Apr 18, 2011.
    13 changes: 13 additions & 0 deletions best-localStorage-polyfill-evar.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    // I mean, seriously, localStorage is supported even by your mum. How about instead of
    // casing the feature out, you give users in-memory (stale) storage instead?
    // If they close your application, they deserve to lose data anyway.

    if (!Modernizr.localstorage) {
    window.localStorage = {
    _data : {},
    setItem : function(id, val) { return this._data[id] = val; },
    getItem : function(id) { return this._data[id]; },
    removeItem : function(id) { return delete this._data[id]; },
    clear : function() { return this._data = {}; }
    };
    }