From 5615b636a4fcda62b0fec57e577903a62710665c Mon Sep 17 00:00:00 2001 From: Florian Dieminger Date: Tue, 27 Jun 2023 15:50:36 +0200 Subject: [PATCH] fix(live-sample): use getElementsByClassName (#9182) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(live-sample): use getElementsByClassName fixes #9177 * 🙈 --- client/src/document/hooks.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client/src/document/hooks.ts b/client/src/document/hooks.ts index 6e3290af8f5d..27b9578dc31e 100644 --- a/client/src/document/hooks.ts +++ b/client/src/document/hooks.ts @@ -159,15 +159,17 @@ function getCodeAndNodesForIframeBySampleClass(cls: string, src: string) { let empty = true; const nodes: Element[] = []; - document.querySelectorAll(`pre.live-sample___${cls}`).forEach((pre) => { - let lang = getLanguage(pre); - if (lang === null) { - return; + [...document.getElementsByClassName(`live-sample___${cls}`)].forEach( + (pre) => { + let lang = getLanguage(pre); + if (lang === null) { + return; + } + empty = false; + nodes.push(pre); + code[lang] += pre.textContent; } - empty = false; - nodes.push(pre); - code[lang] += pre.textContent; - }); + ); return empty ? null : { code, nodes }; }