From 3db81be90953fafaa67712270f0e0130e1c4d044 Mon Sep 17 00:00:00 2001 From: Sartxi Date: Mon, 28 Oct 2024 09:46:13 -0600 Subject: [PATCH] keep contains text function in decorate js --- libs/utils/decorate.js | 10 +++++++++- libs/utils/utils.js | 8 -------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/utils/decorate.js b/libs/utils/decorate.js index 16bf5508b2..c225e38a80 100644 --- a/libs/utils/decorate.js +++ b/libs/utils/decorate.js @@ -1,4 +1,4 @@ -import { createTag, loadStyle, getConfig, createIntersectionObserver, elContainsText } from './utils.js'; +import { createTag, loadStyle, getConfig, createIntersectionObserver } from './utils.js'; const { miloLibs, codeRoot } = getConfig(); @@ -65,6 +65,14 @@ export function decorateIconArea(el) { }); } +function elContainsText(el) { + return !![...el.childNodes].filter((childNode) => { + const { innerText, nodeType, textContent } = childNode; + if (nodeType === Node.ELEMENT_NODE) return innerText.trim() !== ''; + return nodeType === Node.TEXT_NODE && textContent.trim() !== ''; + }).length; +} + export function decorateBlockText(el, config = ['m', 's', 'm'], type = null) { let headings = el.querySelectorAll('h1, h2, h3, h4, h5, h6'); if (!el.classList.contains('default')) { diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 02f78f83c0..11e4548bd5 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -260,14 +260,6 @@ export function isInTextNode(node) { return node.parentElement.firstChild.nodeType === Node.TEXT_NODE; } -export function elContainsText(el) { - return !![...el.childNodes].filter((childNode) => { - const { innerText, nodeType, textContent } = childNode; - if (nodeType === Node.ELEMENT_NODE) return innerText.trim() !== ''; - return nodeType === Node.TEXT_NODE && textContent.trim() !== ''; - }).length; -} - export function createTag(tag, attributes, html, options = {}) { const el = document.createElement(tag); if (html) {