Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed length bug for userData implementation in removeItem()

  • Loading branch information...
commit 59e85adc8f6cc07841f7ada42a6f7a7c15dcb702 1 parent f52450c
Brett Wejrowski authored
Showing with 11 additions and 8 deletions.
  1. +6 −6 README
  2. +4 −1 storage.js
  3. +1 −1  storage.min.js
12 README
View
@@ -1,15 +1,15 @@
/**********************************************************/
- Gracefully Degrading HTML5 Local Storage
+ Cross Browser HTML5 Local Storage Support
/**********************************************************/
Brett Wejrowski
-The Wojo Group
-thewojogroup.com
+Wojo Design
+wojodesign.com
brett@wejrowski.com
-The script implements a replacement for HTML5's localStorage, when it is not supported,
-by using strings of name/value pairs that are stored in cookies. It implements a nearly
-identical interface. You can find the spec of the HTML5 storage at
+The script implements a replacement for HTML5's localStorage when it is not supported.
+It implements a nearly identical interface using userData for IE6-7 and globalStorage
+for FF2-3. You can find the spec of the HTML5 storage at
http://www.w3.org/TR/2009/WD-webstorage-20091222/
5 storage.js
View
@@ -53,7 +53,10 @@ Dual licensed under the MIT or GPL licenses.
div.removeAttribute( key );
div.save( attrKey );
- this.length=0;
+ this.length--;
+ if( this.length < 0){
+ this.length=0;
+ }
},
"clear":function(){
2  storage.min.js
View
@@ -1,3 +1,3 @@
(function(){if(!this.localStorage)if(this.globalStorage)try{this.localStorage=this.globalStorage}catch(e){}else{var a=document.createElement("div");a.style.display="none";document.getElementsByTagName("head")[0].appendChild(a);if(a.addBehavior){a.addBehavior("#default#userdata");var d=this.localStorage={length:0,setItem:function(b,d){a.load("localStorage");b=c(b);a.getAttribute(b)||this.length++;a.setAttribute(b,d);a.save("localStorage")},getItem:function(b){a.load("localStorage");b=c(b);return a.getAttribute(b)},
-removeItem:function(b){a.load("localStorage");b=c(b);a.removeAttribute(b);a.save("localStorage");this.length=0},clear:function(){a.load("localStorage");for(var b=0;attr=a.XMLDocument.documentElement.attributes[b++];)a.removeAttribute(attr.name);a.save("localStorage");this.length=0},key:function(b){a.load("localStorage");return a.XMLDocument.documentElement.attributes[b]}},c=function(a){return a.replace(/[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g,
+removeItem:function(b){a.load("localStorage");b=c(b);a.removeAttribute(b);a.save("localStorage");this.length--;if(0>this.length)this.length=0},clear:function(){a.load("localStorage");for(var b=0;attr=a.XMLDocument.documentElement.attributes[b++];)a.removeAttribute(attr.name);a.save("localStorage");this.length=0},key:function(b){a.load("localStorage");return a.XMLDocument.documentElement.attributes[b]}},c=function(a){return a.replace(/[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g,
"-")};a.load("localStorage");d.length=a.XMLDocument.documentElement.attributes.length}}})();
Please sign in to comment.
Something went wrong with that request. Please try again.