Don't wrap in span if there's nothing

This commit is contained in:
Lim Chee Aun 2025-02-03 21:39:53 +08:00
parent e8dae8f8da
commit 79641b47a5

View file

@ -294,7 +294,7 @@ function _enhanceContent(content, opts = {}) {
// 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) {
if (node.nodeType === Node.TEXT_NODE && node.textContent.trim?.()) {
const span = document.createElement('span');
span.textContent = node.textContent;
dom.replaceChild(span, node);