fix: possible workaround?

This commit is contained in:
Johannes Eder 2021-06-08 18:18:56 +02:00 committed by Gregor Kleen
parent 6aacf40125
commit 757e148032

View File

@ -327,6 +327,7 @@ export class StorageManager {
const url = (options.history && options.history.url) || (this._global.document && this._global.document.location);
const state = this._global.history.state || {};
//alert('Current State of history: ' + JSON.stringify(state));
state[this.namespace] = this._updateStorage({}, value, LOCATION.HISTORY, options);
this._debugLog('_saveToHistory', { state: state, push: push, title: title, url: url});
@ -359,6 +360,12 @@ export class StorageManager {
addHistoryListener(listener, options=this._options, ...args) {
const modified_listener = (function(event, ...listener_args) { // eslint-disable-line no-unused-vars
alert('Event:' + JSON.stringify(event));
//possible solution: popstate event does not have a state
if(event.state === null)
return;
this._global.setTimeout(() => listener(this._getFromHistory(options), ...listener_args));
}).bind(this);
@ -472,10 +479,10 @@ export class StorageManager {
}).catch(console.error);
}
_debugLog() {}
// _debugLog(fName, ...args) {
// console.log(`[DEBUGLOG] StorageManager.${fName}`, { args: args, instance: this });
// }
//_debugLog() {}
_debugLog(fName, ...args) {
console.log(`[DEBUGLOG] StorageManager.${fName}`, { args: args, instance: this });
}
}