chore: tweak Map/Set for better inspect output (#12013)

* chore: tweak Map/Set for better inspect output

* chore: tweak Map/Set for better inspect output

* chore: tweak Map/Set for better inspect output

* chore: tweak Map/Set for better inspect output

* chore: tweak Map/Set for better inspect output

* changeset

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/12024/head
Dominic Gannaway 7 months ago committed by GitHub
parent 50fd94fe61
commit 4cdc3710d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
chore: clear `Map`/`Set` before triggering `$inspect` callbacks

@ -122,17 +122,18 @@ export class ReactiveMap extends Map {
} }
clear() { clear() {
var sources = this.#sources; if (super.size === 0) {
return;
if (super.size !== 0) {
set(this.#size, 0);
for (var s of sources.values()) {
set(s, -1);
}
increment(this.#version);
sources.clear();
} }
// Clear first, so we get nice console.log outputs with $inspect
super.clear(); super.clear();
var sources = this.#sources;
set(this.#size, 0);
for (var s of sources.values()) {
set(s, -1);
}
increment(this.#version);
sources.clear();
} }
#read_all() { #read_all() {

@ -117,19 +117,20 @@ export class ReactiveSet extends Set {
} }
clear() { clear() {
if (super.size !== 0) { if (super.size === 0) {
var sources = this.#sources; return;
}
for (var s of sources.values()) { // Clear first, so we get nice console.log outputs with $inspect
set(s, false); super.clear();
} var sources = this.#sources;
sources.clear(); for (var s of sources.values()) {
set(this.#size, 0); set(s, false);
increment(this.#version);
} }
super.clear(); sources.clear();
set(this.#size, 0);
increment(this.#version);
} }
keys() { keys() {

Loading…
Cancel
Save