-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
For the public get(), set() and remove() methods, if supported == false and any type of exception occurs, the code specific to localStorage will attempt to run, even though supported == false.
For example, this is the current set():
set: function (key, value) {
if (!supported) {
try {
$cookieStore.put(key, value);
return value;
} catch(e) {
$log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
}
}
// THE FOLLOWING LINES RUN WHEN THE CATCH(E) ABOVE IS TRIGGERED
var saver = angular.toJson(value);
storage.setItem(key, saver);
return privateMethods.parseValue(saver);
},Suggest doing the following:
set: function (key, value) {
if (!supported) {
try {
$cookieStore.put(key, value);
return value;
} catch(e) {
$log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
}
}
else { // THIS CODE WILL NOW ONLY EVER EXECUTE IF (supported)
var saver = angular.toJson(value);
storage.setItem(key, saver);
return privateMethods.parseValue(saver);
}
},Metadata
Metadata
Assignees
Labels
No labels