From 3681da11e16b2d837be578997aa5e77e119d0419 Mon Sep 17 00:00:00 2001 From: techsin Date: Sat, 1 Jun 2024 09:16:18 -0400 Subject: [PATCH 1/2] Update index.js --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index aebe104..8fca675 100644 --- a/src/index.js +++ b/src/index.js @@ -159,9 +159,9 @@ export async function highlightElement(elm, lang = elm.className.match(/shj-lang * @param {ShjOptions} [opt={}] Customization options */ export let highlightAll = async (opt) => - document - .querySelectorAll('[class*="shj-lang-"]') - .forEach(elm => highlightElement(elm, undefined, undefined, opt)) + Promise.all( + Array.from(document.querySelectorAll('[class*="shj-lang-"]')) + .map(elem => highlightElement(elm, undefined, undefined, opt))) /** * @typedef {{ match: RegExp, type: string } @@ -183,4 +183,4 @@ export let highlightAll = async (opt) => */ export let loadLanguage = (languageName, language) => { langs[languageName] = language; -} \ No newline at end of file +} From d9ef6a485f9b4692c4b80c7a067e989c60d23cd1 Mon Sep 17 00:00:00 2001 From: techsin Date: Sat, 1 Jun 2024 18:26:15 -0400 Subject: [PATCH 2/2] Update index.js --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 8fca675..417e094 100644 --- a/src/index.js +++ b/src/index.js @@ -159,7 +159,7 @@ export async function highlightElement(elm, lang = elm.className.match(/shj-lang * @param {ShjOptions} [opt={}] Customization options */ export let highlightAll = async (opt) => - Promise.all( + await Promise.all( Array.from(document.querySelectorAll('[class*="shj-lang-"]')) .map(elem => highlightElement(elm, undefined, undefined, opt)))