This commit is contained in:
the-djmaze 2023-02-20 11:50:11 +01:00
parent 3e99f760a4
commit e56d1cf5c6

View file

@ -328,15 +328,16 @@ export const
hasAttribute = name => oElement.hasAttribute(name), hasAttribute = name => oElement.hasAttribute(name),
getAttribute = name => hasAttribute(name) ? oElement.getAttribute(name).trim() : '', getAttribute = name => hasAttribute(name) ? oElement.getAttribute(name).trim() : '',
setAttribute = (name, value) => oElement.setAttribute(name, value), setAttribute = (name, value) => oElement.setAttribute(name, value),
delAttribute = name => oElement.removeAttribute(name); delAttribute = name => {
let value = getAttribute(name);
oElement.removeAttribute(name);
return value;
};
if ('mail-body' === className) { if ('mail-body' === className) {
forEachObjectEntry(tasks, (name, cb) => { forEachObjectEntry(tasks, (name, cb) =>
if (hasAttribute(name)) { hasAttribute(name) && cb(delAttribute(name), oElement)
cb(getAttribute(name), oElement); );
delAttribute(name);
}
});
} else if (msgId && className) { } else if (msgId && className) {
oElement.className = className.replace(/(^|\s+)/g, '$1msg-'); oElement.className = className.replace(/(^|\s+)/g, '$1msg-');
} }
@ -358,13 +359,12 @@ export const
if (!oStyle.backgroundImage) { if (!oStyle.backgroundImage) {
if ('TD' !== name && 'TH' !== name) { if ('TD' !== name && 'TH' !== name) {
// Make width responsive // Make width responsive
if (hasAttribute('width')) { if (hasAttribute('width') && !oStyle.width) {
value = getAttribute('width'); value = delAttribute('width');
oStyle.width = value.includes('%') ? value : value + 'px'; oStyle.width = value.includes('%') ? value : value + 'px';
delAttribute('width');
} }
value = oStyle.width; value = oStyle.width;
if (parseInt(value,10) && !oStyle.maxWidth) { if (100 < parseInt(value,10) && !oStyle.maxWidth) {
oStyle.maxWidth = value; oStyle.maxWidth = value;
oStyle.width = '100%'; oStyle.width = '100%';
} else if (!value?.includes('%')) { } else if (!value?.includes('%')) {
@ -372,9 +372,8 @@ export const
} }
// Make height responsive // Make height responsive
if (hasAttribute('height')) { if (hasAttribute('height')) {
value = getAttribute('height'); value = delAttribute('height');
oStyle.height = value.includes('%') ? value : value + 'px'; oStyle.height = value.includes('%') ? value : value + 'px';
delAttribute('height');
} }
value = oStyle.removeProperty('height'); value = oStyle.removeProperty('height');
if (value && !oStyle.maxHeight) { if (value && !oStyle.maxHeight) {
@ -412,8 +411,7 @@ export const
let skipStyle = false; let skipStyle = false;
if (hasAttribute('src')) { if (hasAttribute('src')) {
value = stripTracking(getAttribute('src')); value = stripTracking(delAttribute('src'));
delAttribute('src');
if ('IMG' === name) { if ('IMG' === name) {
oElement.loading = 'lazy'; oElement.loading = 'lazy';
@ -474,18 +472,15 @@ export const
} }
if (hasAttribute('background')) { if (hasAttribute('background')) {
oStyle.backgroundImage = 'url("' + getAttribute('background') + '")'; oStyle.backgroundImage = 'url("' + delAttribute('background') + '")';
delAttribute('background');
} }
if (hasAttribute('bgcolor')) { if (hasAttribute('bgcolor')) {
oStyle.backgroundColor = getAttribute('bgcolor'); oStyle.backgroundColor = delAttribute('bgcolor');
delAttribute('bgcolor');
} }
if (hasAttribute('color')) { if (hasAttribute('color')) {
oStyle.color = getAttribute('color'); oStyle.color = delAttribute('color');
delAttribute('color');
} }
if (!skipStyle) { if (!skipStyle) {