Move emojis check condition to top

This commit is contained in:
Lim Chee Aun 2024-10-13 11:29:53 +08:00
parent 82163c0b88
commit 66e8bfe18c

View file

@ -116,13 +116,11 @@ function _enhanceContent(content, opts = {}) {
// ====== // ======
// Convert :shortcode: to <img /> // Convert :shortcode: to <img />
let textNodes; let textNodes;
if (enhancedContent.includes(':')) { if (enhancedContent.includes(':') && emojis?.length) {
textNodes = extractTextNodes(dom); textNodes = extractTextNodes(dom);
for (const node of textNodes) { for (const node of textNodes) {
let html = escapeHTML(node.nodeValue); let html = escapeHTML(node.nodeValue);
if (emojis) { html = emojifyText(html, emojis);
html = emojifyText(html, emojis);
}
fauxDiv.innerHTML = html; fauxDiv.innerHTML = html;
node.replaceWith(...fauxDiv.childNodes); node.replaceWith(...fauxDiv.childNodes);
} }