fix array memory leak

proxied-state-each-blocks
Rich Harris 9 months ago committed by Dominic Gannaway
parent 9bf3a6ddf0
commit a77eca23db

@ -27,6 +27,8 @@ function object(value) {
const sources = new Map();
let version = source(0);
const is_array = Array.isArray(value);
return new Proxy(value, {
get(target, prop, receiver) {
let s = sources.get(prop);
@ -50,6 +52,13 @@ function object(value) {
const s = sources.get(prop);
if (s) set(s, magic(value));
if (is_array && prop === 'length') {
for (let i = value; i < target.length; i += 1) {
const s = sources.get(i + '');
if (s) set(s, undefined);
}
}
if (!(prop in target)) increment(version);
target[prop] = value;

Loading…
Cancel
Save