Skip to content
Snippets Groups Projects
Commit e8459b88 authored by Antoine Guenet's avatar Antoine Guenet
Browse files

[FIX] web_editor: prevent 'px' in width/height attributes


In width and height attributes, the "px" unit is implicit. In some cases
we introduced it explicitly, which is unexpected.

closes odoo/odoo#125146

Signed-off-by: default avatarDavid Monjoie (dmo) <dmo@odoo.com>
parent e471fd82
Branches
Tags
No related merge requests found
......@@ -89,8 +89,8 @@ function attachmentThumbnailToLinkImg($editable) {
const image = document.createElement('img');
image.setAttribute('src', _getStylePropertyValue(link, 'background-image').replace(/(^url\(['"])|(['"]\)$)/g, ''));
// Note: will trigger layout thrashing.
image.setAttribute('height', Math.max(1, _getHeight(link)) + 'px');
image.setAttribute('width', Math.max(1, _getWidth(link)) + 'px');
image.setAttribute('height', Math.max(1, _getHeight(link)));
image.setAttribute('width', Math.max(1, _getWidth(link)));
link.prepend(image);
};
}
......@@ -413,7 +413,7 @@ function classToStyle($editable, cssRules) {
writes.push(() => {
node.setAttribute('style', style);
if (node.style.width) {
node.setAttribute('width', node.style.width);
node.setAttribute('width', ('' + node.style.width).replace('px', ''));
}
});
}
......@@ -487,7 +487,7 @@ function toInline($editable, cssRules, $iframe) {
if (!value) {
value = attributeName === 'width' ? _getWidth(image) : _getHeight(image);;
}
image.setAttribute(attributeName, value);
image.setAttribute(attributeName, ('' + value).replace('px', ''));
};
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment