Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/playground/src/sidebar/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,18 @@ function rewireLoggingToElement(
const nameWithoutObject = name && name === "Object" ? "" : htmlEscape(name)
const prefix = nameWithoutObject ? `${nameWithoutObject}: ` : ""

// JSON.stringify omits any keys with a value of undefined. To get around this, we replace undefined with the text __undefined__ and then do a global replace using regex back to keyword undefined
textRep =
prefix +
JSON.stringify(arg, (_, value) => (value === undefined ? "__undefined__" : value), 2).replace(
/"__undefined__"/g,
"undefined"
)
JSON.stringify(
arg,
(_, value) => {
// JSON.stringify omits any keys with a value of undefined. To get around this, we replace undefined with the text __undefined__ and then do a global replace using regex back to keyword undefined
if (value === undefined) return "__undefined__"
if (typeof value === 'bigint') return `BigInt('${value.toString()}')`
return value
},
2
).replace(/"__undefined__"/g, "undefined")

textRep = htmlEscape(textRep)
} else {
Expand Down