Fix oversights in forwarded state caching

This commit is contained in:
Talia 2023-12-23 21:04:52 +01:00
parent 99d791921e
commit b46c5d1d5c
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E
2 changed files with 3 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{
"name": "skooma",
"version": "1.4.0",
"version": "1.4.1",
"author": "darkwiiplayer",
"license": "Unlicense",
"main": "skooma.js",

View file

@ -88,12 +88,12 @@ export class State extends EventTarget {
forward(property="value", fallback) {
if (!this.#forwardCache) this.#forwardCache = new Map()
const cached = this.#forwardCache.get(property).deref()
const cached = this.#forwardCache.get(property)?.deref()
if (cached) {
return cached
} else {
const forwarded = new ForwardState(this, property, fallback)
ref = new Weakref(forwarded)
const ref = new WeakRef(forwarded)
this.#forwardCache.set(property, ref)
forwardFinalizationRegistry.register(forwarded, [this.#forwardCache, property])
return forwarded