[FIX] web_editor: prevent undefined class/style

The `_wrap` util function of `convert_inline` was not checking if
`className` and `style` were defined before adding them to the wrapper
element, leading to things like `<div class="undefined">element</div>`.

X-original-commit: 9fd6e069d07c3f7964511af7289d95c970d11b3e
Part-of: odoo/odoo#124465
This commit is contained in:
Antoine Guenet
2023-06-09 17:01:43 +02:00
parent 6b2a18be8a
commit c33ecdf27c
@@ -1623,8 +1623,12 @@ function _normalizeStyle(style) {
*/
function _wrap(element, wrapperTag, wrapperClass, wrapperStyle) {
const wrapper = document.createElement(wrapperTag);
wrapper.className = wrapperClass;
wrapper.style.cssText = wrapperStyle;
if (wrapperClass) {
wrapper.className = wrapperClass;
}
if (wrapperStyle) {
wrapper.style.cssText = wrapperStyle;
}
element.parentElement.insertBefore(wrapper, element);
wrapper.append(element);
return wrapper;