Skip to content

Commit

Permalink
fix: improve REPL stringify logic (sveltejs#11609)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
trueadm and dummdidumm authored May 14, 2024
1 parent fd43702 commit a8a5bb6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion sites/svelte-5-preview/src/lib/Output/srcdoc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a8a5bb6

Please sign in to comment.