From 0c0b20766753ad00aba6ec50fd2d9023b53cc306 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Tue, 18 Jan 2022 20:08:02 +0000 Subject: [PATCH] Initialize DOMParser only once --- assets/ts/search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/ts/search.tsx b/assets/ts/search.tsx index a548d8b..495961d 100644 --- a/assets/ts/search.tsx +++ b/assets/ts/search.tsx @@ -210,9 +210,9 @@ class Search { /// Not fetched yet const jsonURL = this.form.dataset.json; this.data = await fetch(jsonURL).then(res => res.json()); + const parser = new DOMParser(); for (const item of this.data) { - const parser = new DOMParser(); item.content = parser.parseFromString(item.content, 'text/html').body.innerText; } }