From 0f3b2b4a9240eff87b3be34c25e63df354479754 Mon Sep 17 00:00:00 2001 From: Kuberdenis <40846846+kubeden@users.noreply.github.com> Date: Fri, 12 Jul 2024 20:11:42 +0300 Subject: [PATCH] Let templates have plaintext as contents (fixes 2702) (#2708) let templates have plaintext as contents (fixes 2702) --- src/htmx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/htmx.js b/src/htmx.js index 401e1585..eaec845d 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -1854,7 +1854,7 @@ var htmx = (function() { findAndSwapOobElements(fragment, settleInfo) forEach(findAll(fragment, 'template'), /** @param {HTMLTemplateElement} template */function(template) { findAndSwapOobElements(template.content, settleInfo) - if (template.content.childElementCount === 0) { + if (template.content.childElementCount === 0 && template.content.textContent.trim() === '') { // Avoid polluting the DOM with empty templates that were only used to encapsulate oob swap template.remove() }