[FIX] web_editor: preserve content around on unlink images

Before this, we were considering only the case where only a single
element is wrapped by the anchor tag, like `<a><img></a>`. So it simply
replaces parent node `<a>` with childNode `<img>`. However, cases like
`<a>text<img><a>` (where there are multiple element within the <a> tag)
were failing.

To handle such cases, this commit replaced the code that considering
multiple childNodes and replacing parentNode with all the childNode.

task-3231606

closes odoo/odoo#132531

X-original-commit: 08432308819e83fd0122a8e87170ec8ff27ca2a1
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Divyesh Vyas (divy) <divy@odoo.com>
This commit is contained in:
divy-odoo
2023-08-21 17:01:07 +02:00
parent f7d43662e3
commit ce49ff9742
@@ -5537,7 +5537,9 @@ registry.ReplaceMedia = SnippetOptionWidget.extend({
this.$target[0].src = src;
}
} else {
parentEl.replaceWith(this.$target[0]);
const fragment = document.createDocumentFragment();
fragment.append(...parentEl.childNodes);
parentEl.replaceWith(fragment);
}
},
/**