From a8a5bb668f4be426d1c717487950fcb864ca4909 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Tue, 14 May 2024 12:47:35 +0100 Subject: [PATCH] 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 <5968653+dummdidumm@users.noreply.github.com> --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> --- .../src/lib/Output/srcdoc/index.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sites/svelte-5-preview/src/lib/Output/srcdoc/index.html b/sites/svelte-5-preview/src/lib/Output/srcdoc/index.html index 9476fbba51..2062beef65 100644 --- a/sites/svelte-5-preview/src/lib/Output/srcdoc/index.html +++ b/sites/svelte-5-preview/src/lib/Output/srcdoc/index.html @@ -274,7 +274,22 @@ function stringify(args) { try { - return JSON.stringify(args); + return JSON.stringify(args, (key, value) => { + // if we don't do this, our Set/Map from svelte/reactivity would show up wrong in the console + if (value instanceof Map) { + return { + type: 'Map', + value + }; + } + if (value instanceof Set) { + return { + type: 'Set', + value + }; + } + return value; + }); } catch (error) { return null; }