Skip to content

Commit

Permalink
fix(core/hightlight): fall back to textContent for Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Mar 29, 2021
1 parent d348f14 commit 1e6eadd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1e6eadd

Please sign in to comment.