Skip to content

Commit a8a5bb6

Browse files
trueadmdummdidumm
andauthored
fix: improve REPL stringify logic (#11609)
* fix: improve REPL stringify logic * fix: improve REPL stringify logic * Update sites/svelte-5-preview/src/lib/Output/srcdoc/index.html Co-authored-by: Simon H <[email protected]> --------- Co-authored-by: Simon H <[email protected]>
1 parent fd43702 commit a8a5bb6

File tree

1 file changed

+16
-1
lines changed
  • sites/svelte-5-preview/src/lib/Output/srcdoc

1 file changed

+16
-1
lines changed

sites/svelte-5-preview/src/lib/Output/srcdoc/index.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,22 @@
274274

275275
function stringify(args) {
276276
try {
277-
return JSON.stringify(args);
277+
return JSON.stringify(args, (key, value) => {
278+
// if we don't do this, our Set/Map from svelte/reactivity would show up wrong in the console
279+
if (value instanceof Map) {
280+
return {
281+
type: 'Map',
282+
value
283+
};
284+
}
285+
if (value instanceof Set) {
286+
return {
287+
type: 'Set',
288+
value
289+
};
290+
}
291+
return value;
292+
});
278293
} catch (error) {
279294
return null;
280295
}

0 commit comments

Comments
 (0)