Skip to content

Commit e7c465c

Browse files
author
Sebastian Gronewold
committed
Handling for explicit usage of cookie fallback
If the user explicitely set the storage type to cookie also the getFromLlocalStorage and addToLocalStorage method should use the cookie fallback.
1 parent 7ef86fb commit e7c465c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

angular-local-storage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ angularLocalStorage.provider('localStorageService', function() {
121121
var addToLocalStorage = function (key, value) {
122122

123123
// If this browser does not support local storage use cookies
124-
if (!browserSupportsLocalStorage) {
124+
if (!browserSupportsLocalStorage || this.storageType === 'cookie') {
125125
$rootScope.$broadcast('LocalStorageModule.notification.warning', 'LOCAL_STORAGE_NOT_SUPPORTED');
126126
if (notify.setItem) {
127127
$rootScope.$broadcast('LocalStorageModule.notification.setitem', {key: key, newvalue: value, storageType: 'cookie'});
@@ -153,7 +153,7 @@ angularLocalStorage.provider('localStorageService', function() {
153153
// Example use: localStorageService.get('library'); // returns 'angular'
154154
var getFromLocalStorage = function (key) {
155155

156-
if (!browserSupportsLocalStorage) {
156+
if (!browserSupportsLocalStorage || this.storageType === 'cookie') {
157157
$rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');
158158
return getFromCookies(key);
159159
}

0 commit comments

Comments
 (0)