From 1e6eaddf1143d399e82908197219a2f8d10c1da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Mon, 29 Mar 2021 17:14:34 +1100 Subject: [PATCH] fix(core/hightlight): fall back to textContent for Safari --- src/core/highlight.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/highlight.js b/src/core/highlight.js index 294ae9298a..28d2da7edd 100644 --- a/src/core/highlight.js +++ b/src/core/highlight.js @@ -33,7 +33,9 @@ async function highlightElement(elem) { const languages = getLanguageHint(elem.classList); let response; try { - response = await sendHighlightRequest(elem.innerText, languages); + // Safari return "" for innerText when the document is hidden + const code = elem.innerText ? elem.innerText : elem.textContent; + response = await sendHighlightRequest(code, languages); } catch (err) { console.error(err); return;