Skip to content

Commit

Permalink
Fix namespacing bugs in localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
tofumatt committed Oct 16, 2014
1 parent 9e8840b commit a2ba81d
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = exports = function(grunt) {
banner:
'/*!\n' +
' localForage -- Offline Storage, Improved\n' +
' Version 1.0.3\n' +
' Version 1.0.4\n' +
' http://mozilla.github.io/localForage\n' +
' (c) 2013-2014 Mozilla, Apache License 2.0\n' +
'*/\n'
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "localforage",
"version": "1.0.3",
"version": "1.0.4",
"main": [
"dist/localforage.js"
],
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "localforage",
"version": "1.0.3",
"version": "1.0.4",
"dependencies": {
"then/promise": "5.0.0"
},
Expand Down
13 changes: 6 additions & 7 deletions dist/localforage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
localForage -- Offline Storage, Improved
Version 1.0.3
Version 1.0.4
http://mozilla.github.io/localForage
(c) 2013-2014 Mozilla, Apache License 2.0
*/
Expand Down Expand Up @@ -1220,8 +1220,9 @@ requireModule('promise/polyfill').polyfill();
var keys = [];

for (var i = 0; i < length; i++) {
keys.push(localStorage.key(i)
.substring(dbInfo.keyPrefix.length));
if (localStorage.key(i).indexOf(dbInfo.keyPrefix) === 0) {
keys.push(localStorage.key(i).substring(dbInfo.keyPrefix.length));
}
}

resolve(keys);
Expand All @@ -1236,10 +1237,8 @@ requireModule('promise/polyfill').polyfill();
function length(callback) {
var self = this;
var promise = new Promise(function(resolve, reject) {
self.ready().then(function() {
var result = localStorage.length;

resolve(result);
self.keys().then(function(keys) {
resolve(keys.length);
})["catch"](reject);
});

Expand Down
2 changes: 1 addition & 1 deletion dist/localforage.min.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions dist/localforage.nopromises.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
localForage -- Offline Storage, Improved
Version 1.0.3
Version 1.0.4
http://mozilla.github.io/localForage
(c) 2013-2014 Mozilla, Apache License 2.0
*/
Expand Down Expand Up @@ -537,8 +537,9 @@
var keys = [];

for (var i = 0; i < length; i++) {
keys.push(localStorage.key(i)
.substring(dbInfo.keyPrefix.length));
if (localStorage.key(i).indexOf(dbInfo.keyPrefix) === 0) {
keys.push(localStorage.key(i).substring(dbInfo.keyPrefix.length));
}
}

resolve(keys);
Expand All @@ -553,10 +554,8 @@
function length(callback) {
var self = this;
var promise = new Promise(function(resolve, reject) {
self.ready().then(function() {
var result = localStorage.length;

resolve(result);
self.keys().then(function(keys) {
resolve(keys.length);
})["catch"](reject);
});

Expand Down
2 changes: 1 addition & 1 deletion dist/localforage.nopromises.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"storage",
"websql"
],
"version": "1.0.3",
"version": "1.0.4",
"homepage": "https://github.com/mozilla/localForage",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion site/localforage.min.js

Large diffs are not rendered by default.

0 comments on commit a2ba81d

Please sign in to comment.