html component to do dom purify.

This commit is contained in:
Jason Schwarzenberger
2020-12-02 14:35:49 +13:00
parent f524ecec7b
commit 8c40124e07
4 changed files with 22 additions and 41 deletions

View File

@@ -1,8 +1,6 @@
<script>
import DOMPurify from "dompurify";
import { onMount } from "svelte";
import Time from "../components/Time.svelte";
import Html from "../components/Html.svelte";
export let story;
export let comment;
@@ -11,12 +9,6 @@
let author = (comment.author || "").replace(" ", "");
let id = `${author}-${comment.date}`;
let html;
onMount(() => {
html = DOMPurify.sanitize(comment.text);
});
function toggleComments() {
showComments = !showComments;
}
@@ -94,7 +86,7 @@
</header>
<section class={showComments ? 'comment-text' : 'comment-text is-collapsed'}>
{@html html}
<Html html={comment.text} />
</section>
{#if !showComments}