From 4e032c3aa5bc73000cfe8c8fd10eae0c6f24f9e7 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 9 Aug 2023 23:20:35 +0100 Subject: [PATCH] refactor: render katex in delegate. window.onload is redundant --- src/ts/app.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ts/app.ts b/src/ts/app.ts index 0c6c102..1049c19 100644 --- a/src/ts/app.ts +++ b/src/ts/app.ts @@ -26,14 +26,12 @@ declare const katex: any; const list = document.querySelectorAll('[data-bs-toggle="tooltip"]'); list.forEach((el: Element) => new bootstrap.Tooltip(el)); - window.onload = function () { - const tex = document.getElementsByClassName("math"); - Array.prototype.forEach.call(tex, function (el) { - let content = el.textContent.trim(); - if (content.startsWith("\\[")) content = content.slice(2); - if (content.endsWith("\\]")) content = content.slice(0, -2); + const tex = document.getElementsByClassName("math"); + Array.prototype.forEach.call(tex, function (el) { + let content = el.textContent.trim(); + if (content.startsWith("\\[")) content = content.slice(2); + if (content.endsWith("\\]")) content = content.slice(0, -2); - katex.render(content, el); - }); - }; + katex.render(content, el); + }); })();