fix(storage-manager): clear is working without options as well

This commit is contained in:
Johannes Eder 2021-08-12 22:30:42 +02:00 committed by Sarah Vaupel
parent acdeea0b3d
commit f1c50e137f

View File

@ -186,14 +186,14 @@ export class StorageManager {
}
}
clear(options) {
clear(options=this._options) {
this._debugLog('clear', options);
if (options && options.location !== undefined && !Object.values(LOCATION).includes(options.location)) {
throw new Error('StorageManager.clear called with unsupported location option');
}
const locations = options && options.location !== undefined ? [options.location] : LOCATION_SHADOWING;
const locations = ((options !== undefined) && options.location !== undefined)? [options.location] : this._location_shadowing;
for (const location of locations) {
switch (location) {
@ -204,7 +204,10 @@ export class StorageManager {
case LOCATION.WINDOW:
return this._clearWindow();
case LOCATION.HISTORY:
return this._clearHistory(options && options.history);
if(options.history)
return this._clearHistory(options && options.history);
else
return;
default:
console.error('StorageManager.clear cannot clear with unsupported location');
}