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>
pull/11608/head
Dominic Gannaway 1 year ago committed by GitHub
parent fd437024f5
commit a8a5bb668f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -274,7 +274,22 @@
function stringify(args) { function stringify(args) {
try { 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) { } catch (error) {
return null; return null;
} }

Loading…
Cancel
Save