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,9 +122,12 @@ export class ReactiveMap extends Map {
}
clear() {
if (super.size === 0) {
return;
}
// Clear first, so we get nice console.log outputs with $inspect
super.clear();
var sources = this.#sources;
if (super.size !== 0) {
set(this.#size, 0);
for (var s of sources.values()) {
set(s, -1);
@ -132,8 +135,6 @@ export class ReactiveMap extends Map {
increment(this.#version);
sources.clear();
}
super.clear();
}
#read_all() {
get(this.#version);

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

Loading…
Cancel
Save