Skip to content

Commit 63c03d7

Browse files
committed
fix: prevent HTMLElement serialization to fail
1 parent 63f9fa1 commit 63c03d7

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

packages/shared-utils/src/util.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -359,20 +359,29 @@ export function getCustomFunctionDetails (func: Function): CustomState {
359359
}
360360

361361
export function getCustomHTMLElementDetails (value: HTMLElement): CustomState {
362-
return {
363-
_custom: {
364-
type: 'HTMLElement',
365-
display: `<span class="opacity-30">&lt;</span><span class="text-blue-500">${value.tagName.toLowerCase()}</span><span class="opacity-30">&gt;</span>`,
366-
value: namedNodeMapToObject(value.attributes),
367-
actions: [
368-
{
369-
icon: 'input',
370-
tooltip: 'Log element to console',
371-
action: () => {
372-
console.log(value)
362+
try {
363+
return {
364+
_custom: {
365+
type: 'HTMLElement',
366+
display: `<span class="opacity-30">&lt;</span><span class="text-blue-500">${value.tagName.toLowerCase()}</span><span class="opacity-30">&gt;</span>`,
367+
value: namedNodeMapToObject(value.attributes),
368+
actions: [
369+
{
370+
icon: 'input',
371+
tooltip: 'Log element to console',
372+
action: () => {
373+
console.log(value)
374+
}
373375
}
374-
}
375-
]
376+
]
377+
}
378+
}
379+
} catch (e) {
380+
return {
381+
_custom: {
382+
type: 'HTMLElement',
383+
display: `<span class="text-blue-500">${String(value)}</span>`
384+
}
376385
}
377386
}
378387
}

0 commit comments

Comments
 (0)