Skip to content
Snippets Groups Projects
Commit 76cb7393 authored by Rodolpho Lima's avatar Rodolpho Lima
Browse files

[FIX] web_editor: remove non-connected nodes in applyColor command


Before this commit, the `applyColor` command returned non-connected nodes
(nodes with no parent) in some not well-defined situations, leading to a Warning
when `selection.addRange()` was called by `_processAndApplyColor` with
such non-connected node as argument.

This commit properly removes such non-connected nodes from the array returned
by `applyColor`.

closes odoo/odoo#118419

Signed-off-by: default avatarDavid Monjoie (dmo) <dmo@odoo.com>
parent d9b8f7d4
Branches
Tags
No related merge requests found
......@@ -620,13 +620,15 @@ export const editorCommands = {
return font;
});
// Color the selected <font>s and remove uncolored fonts.
for (const font of new Set(fonts)) {
const fontsSet = new Set(fonts);
for (const font of fontsSet) {
colorElement(font, color, mode);
if (!hasColor(font, mode) && !font.hasAttribute('style')) {
for (const child of [...font.childNodes]) {
font.parentNode.insertBefore(child, font);
}
font.parentNode.removeChild(font);
fontsSet.delete(font);
}
}
restoreCursor();
......@@ -638,7 +640,7 @@ export const editorCommands = {
newSelection.removeAllRanges();
newSelection.addRange(range);
}
return fonts;
return [...fontsSet];
},
// Table
insertTable: (editor, { rowNumber = 2, colNumber = 2 } = {}) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment