fix: address map reactivity regression (#11882)

pull/11889/head
Dominic Gannaway 1 year ago committed by GitHub
parent 35f92cf683
commit 0a7de87eb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: address map reactivity regression

@ -140,18 +140,25 @@ export class ReactiveMap extends Map {
super.clear();
}
#read_all() {
get(this.#version);
for (var [, s] of this.#sources) {
get(s);
}
}
keys() {
get(this.#version);
return super.keys();
}
values() {
get(this.#version);
this.#read_all();
return super.values();
}
entries() {
get(this.#version);
this.#read_all();
return super.entries();
}

@ -36,7 +36,30 @@ test('map.values()', () => {
map.clear();
});
assert.deepEqual(log, [5, true, [1, 2, 3, 4, 5], 4, false, [1, 2, 4, 5], 0, false, []]);
flushSync(() => {
map.set(3, 3);
});
flushSync(() => {
map.set(3, 4);
});
assert.deepEqual(log, [
5,
true,
[1, 2, 3, 4, 5],
4,
false,
[1, 2, 4, 5],
0,
false,
[],
1,
true,
[3],
true,
[4]
]);
cleanup();
});

Loading…
Cancel
Save