[FIX] web_editor: round px values converted from rem to 1 decimal place
When converting an rem size to a pixel size, we sometimes ended up with values with many decimal places. This rounds them to one decimal place. X-original-commit: 8f8d5bf93f60560040a37695c3439600d5d88287 Part-of: odoo/odoo#81540
This commit is contained in:
@@ -788,7 +788,8 @@ function normalizeRem($editable) {
|
||||
const remMatch = node.getAttribute('style').match(/[\d\.]+\s*rem/g);
|
||||
for (const rem of remMatch || []) {
|
||||
const remValue = parseFloat(rem.replace(/[^\d\.]/g, ''));
|
||||
node.setAttribute('style', node.getAttribute('style').replace(rem, remValue * rootFontSize + 'px'));
|
||||
const pxValue = Math.round(remValue * rootFontSize * 10) / 10;
|
||||
node.setAttribute('style', node.getAttribute('style').replace(rem, pxValue + 'px'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user