From 9d644624dd3555d9995d7dce0b2aee05644a0506 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Fri, 2 Jun 2023 10:41:08 +0000 Subject: [PATCH] [FIX] web_editor: only clean ZWS in text nodes actually containing ZWS When cleaning zero-width spaces (ZWS) in the editor, we were replacing the node values of all text nodes descending from the node we were cleaning, regardless of whether they contained a ZWS or not. This could lead to wrong selections in the tests when arbitrarily changing the value of a text node in the selection. Part-of: odoo/odoo#111119 --- .../static/src/js/editor/odoo-editor/src/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js index 1e836c8a770..0c11e8fd9b1 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js @@ -2578,6 +2578,6 @@ export function isMacOS() { */ export function cleanZWS(node) { [node, ...descendants(node)] - .filter(node => node.nodeType === Node.TEXT_NODE) + .filter(node => node.nodeType === Node.TEXT_NODE && node.nodeValue.includes('\u200B')) .forEach(node => node.nodeValue = node.nodeValue.replace(/\u200B/g, '')); }