From eb98c0713afb47d69da54ca6b80a2acf3a20cff0 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Wed, 2 Mar 2022 16:11:38 +0100 Subject: [PATCH] Improved cleanHtml() handling of table width and content --- dev/Common/Html.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dev/Common/Html.js b/dev/Common/Html.js index 3780f091c..58a27321c 100644 --- a/dev/Common/Html.js +++ b/dev/Common/Html.js @@ -94,8 +94,8 @@ export const 'INPUT','OUTPUT','SELECT','BUTTON','TEXTAREA', 'BGSOUND','KEYGEN','SOURCE','OBJECT','EMBED','APPLET','IFRAME','FRAME','FRAMESET','VIDEO','AUDIO','AREA','MAP' ], - inlineTags = [ - 'A','B','EM','I','SPAN','STRONG','O:P' + nonEmptyTags = [ + 'A','B','EM','I','SPAN','STRONG','O:P','TABLE' ]; tpl.innerHTML = html @@ -131,7 +131,7 @@ export const // || (oStyle.maxHeight && 1 > parseFloat(oStyle.maxHeight) // || (oStyle.maxWidth && 1 > parseFloat(oStyle.maxWidth) // || ('0' === oStyle.opacity - || (inlineTags.includes(name) && '' == oElement.textContent.trim()) + || (nonEmptyTags.includes(name) && ('' == oElement.textContent.trim() && !oElement.querySelector('img'))) ) { oElement.remove(); return; @@ -173,11 +173,14 @@ export const }); } - else if ('TABLE' === name && hasAttribute('width')) { - value = getAttribute('width'); - if (!value.includes('%')) { + else if ('TABLE' === name) { + if (hasAttribute('width')) { + oStyle.width = getAttribute('width'); delAttribute('width'); - oStyle.maxWidth = value + 'px'; + } + value = oStyle.width; + if (value && !value.includes('%')) { + oStyle.maxWidth = value; oStyle.width = '100%'; } }