Skip to content

Commit a4e9931

Browse files
committed
Added error treatment on syntaxHighlight when passing a function or symbol as data prop
1 parent 3ab9cde commit a4e9931

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib/client/SuperDebug.svelte

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@
6767
* @returns {string}
6868
*/
6969
function syntaxHighlight(json) {
70+
switch (typeof json) {
71+
case "function": {
72+
return `<span class="function">[function ${json.name ?? 'unnamed'}]</span>`;
73+
}
74+
case "symbol": {
75+
return `<span class="symbol">${json.toString()}</span>`;
76+
}
77+
}
78+
7079
const encodedString = JSON.stringify(
7180
json,
7281
function (key, value) {
@@ -385,6 +394,10 @@
385394
color: var(--sd-code-function, #f06962);
386395
}
387396
397+
:global(.super-debug--code .symbol) {
398+
color: var(--sd-code-symbol, #77e9c3);
399+
}
400+
388401
.super-debug pre::-webkit-scrollbar {
389402
width: var(--sd-sb-width, 1.25rem);
390403
height: var(--sd-sb-height, 1.25rem);

0 commit comments

Comments
 (0)