Skip to content

Commit 24e017f

Browse files
Algorithm5838github-actions[bot]
authored andcommitted
perf: skip re-sanitizing unchanged HTML tokens
1 parent 4bd7d6c commit 24e017f

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/lib/components/chat/Messages/Markdown/HTMLToken.svelte

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010
1111
let html: string | null = null;
1212
13-
$: if (token.type === 'html' && token?.text) {
14-
html = DOMPurify.sanitize(token.text);
15-
} else {
16-
html = null;
17-
}
13+
$: text = token.type === 'html' ? token?.text : null;
14+
$: html = text ? DOMPurify.sanitize(text) : null;
1815
</script>
1916

2017
{#if token.type === 'html'}

0 commit comments

Comments
 (0)