Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "localstorage",
"main": "dist/local-storage.js",
"version": "1.4.1",
"version": "1.4.3",
"homepage": "https://github.com/bevacqua/local-storage",
"authors": [
"Nicolas Bevacqua <nicolasbevacqua@gmail.com>"
Expand Down
10 changes: 9 additions & 1 deletion changelog.markdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# 1.4.1
# 1.4.3

Make it work inside iframe (where localStorage doesn't work cross domains, so we use stub)

# 1.4.2 Keyboard Smasher

Fixed a bug where `local-storage` wouldn't retrieve any values unless they had a `'key'` key

# 1.4.1 Bear Hunt

Fix a bug where `local-storage` would throw in IE when using the `file://` protocol

Expand Down
15 changes: 13 additions & 2 deletions dist/local-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@

var stub = require('./stub');
var tracking = require('./tracking');
var ls = 'localStorage' in global && global.localStorage ? global.localStorage : stub;

var localStorageAvailable = function () {
try {
global.localStorage.setItem('_test-local-storage-availability_', '1');
global.localStorage.removeItem('_test-local-storage-availability_');
return true;
} catch (e) {
return false;
}
};

var ls = localStorageAvailable() ? global.localStorage : stub;

function accessor (key, value) {
if (arguments.length === 1) {
Expand Down Expand Up @@ -50,7 +61,7 @@ module.exports = accessor;
var ms = {};

function getItem (key) {
return 'key' in ms ? ms[key] : null;
return key in ms ? ms[key] : null;
}

function setItem (key, value) {
Expand Down
13 changes: 12 additions & 1 deletion local-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

var stub = require('./stub');
var tracking = require('./tracking');
var ls = 'localStorage' in global && global.localStorage ? global.localStorage : stub;

var localStorageAvailable = function () {
try {
global.localStorage.setItem('_test-local-storage-availability_', '1');
global.localStorage.removeItem('_test-local-storage-availability_');
return true;
} catch (e) {
return false;
}
};

var ls = localStorageAvailable() ? global.localStorage : stub;

function accessor (key, value) {
if (arguments.length === 1) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "local-storage",
"version": "1.4.1",
"version": "1.4.3",
"description": "A simplified localStorage API that just works",
"main": "local-storage.js",
"repository": {
Expand Down