From 8d98ccff8352a20c9ab7e5340b75e458117c8022 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 18 Oct 2024 17:22:48 +0800 Subject: [PATCH] Fix cloak mode issues on Safari --- src/utils/enhance-content.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils/enhance-content.js b/src/utils/enhance-content.js index caf05b1b..dc65480d 100644 --- a/src/utils/enhance-content.js +++ b/src/utils/enhance-content.js @@ -290,6 +290,17 @@ function _enhanceContent(content, opts = {}) { } } + // FIX CLOAK MODE FOR SAFARI + // Workaround for Safari so that `text-decoration-thickness` works + // Wrap child text nodes in spans + for (const node of dom.childNodes) { + if (node.nodeType === Node.TEXT_NODE) { + const span = document.createElement('span'); + span.textContent = node.textContent; + dom.replaceChild(span, node); + } + } + if (postEnhanceDOM) { queueMicrotask(() => postEnhanceDOM(dom)); // postEnhanceDOM(dom); // mutate dom