Fix smaller problems in storage state
This commit is contained in:
parent
8c01bd83ca
commit
2c2adba2b6
1 changed files with 2 additions and 2 deletions
4
state.js
4
state.js
|
@ -93,7 +93,7 @@ export class StoredState extends State {
|
||||||
|
|
||||||
constructor(init, options={}) {
|
constructor(init, options={}) {
|
||||||
super({}, options)
|
super({}, options)
|
||||||
this.#storage = options.storage ?? localStorage
|
this.#storage = options.storage ?? localStorage ?? new MapStorage()
|
||||||
this.#valueKey = options.key ?? 'value'
|
this.#valueKey = options.key ?? 'value'
|
||||||
|
|
||||||
// Initialise storage from defaults
|
// Initialise storage from defaults
|
||||||
|
@ -114,7 +114,7 @@ export class StoredState extends State {
|
||||||
addEventListener("storage", event => {
|
addEventListener("storage", event => {
|
||||||
let prop = event.key
|
let prop = event.key
|
||||||
if (prop === this.#valueKey) prop = 'value'
|
if (prop === this.#valueKey) prop = 'value'
|
||||||
this.emit(prop, event.newValue)
|
this.emit(prop, JSON.parse(event.newValue))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue