Fix oversights in forwarded state caching
This commit is contained in:
parent
99d791921e
commit
b46c5d1d5c
2 changed files with 3 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "skooma",
|
"name": "skooma",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"author": "darkwiiplayer",
|
"author": "darkwiiplayer",
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"main": "skooma.js",
|
"main": "skooma.js",
|
||||||
|
|
4
state.js
4
state.js
|
@ -88,12 +88,12 @@ export class State extends EventTarget {
|
||||||
|
|
||||||
forward(property="value", fallback) {
|
forward(property="value", fallback) {
|
||||||
if (!this.#forwardCache) this.#forwardCache = new Map()
|
if (!this.#forwardCache) this.#forwardCache = new Map()
|
||||||
const cached = this.#forwardCache.get(property).deref()
|
const cached = this.#forwardCache.get(property)?.deref()
|
||||||
if (cached) {
|
if (cached) {
|
||||||
return cached
|
return cached
|
||||||
} else {
|
} else {
|
||||||
const forwarded = new ForwardState(this, property, fallback)
|
const forwarded = new ForwardState(this, property, fallback)
|
||||||
ref = new Weakref(forwarded)
|
const ref = new WeakRef(forwarded)
|
||||||
this.#forwardCache.set(property, ref)
|
this.#forwardCache.set(property, ref)
|
||||||
forwardFinalizationRegistry.register(forwarded, [this.#forwardCache, property])
|
forwardFinalizationRegistry.register(forwarded, [this.#forwardCache, property])
|
||||||
return forwarded
|
return forwarded
|
||||||
|
|
Loading…
Reference in a new issue