[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
This commit is contained in:
@@ -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, ''));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user