[FIX] web_editor: scope getFurthestUneditableParent in editable
This commit fixes the method so that it is not allowed to probe outside the boundaries of the `root` editable element, no matter the value of `parentLimit`. This also allows to not specify `parentLimit` (becomes the editable element by default). task-3425395 X-original-commit: ffeb1abcc675dd05fb9546e39aac4498e510bbbc Part-of: odoo/odoo#128631
This commit is contained in:
@@ -262,19 +262,22 @@ export function findNode(domPath, findCallback = () => true, stopCallback = () =
|
||||
* the range (so that it is not possible to partially remove them)
|
||||
*
|
||||
* @param {Node} node
|
||||
* @param {Node} parentLimit non-inclusive furthest parent allowed
|
||||
* @param {Node} [parentLimit=undefined] non-inclusive furthest parent allowed
|
||||
* @returns {Node} uneditable parent if it exists
|
||||
*/
|
||||
export function getFurthestUneditableParent(node, parentLimit) {
|
||||
if (node === parentLimit || !parentLimit.contains(node)) {
|
||||
if (node === parentLimit || (parentLimit && !parentLimit.contains(node))) {
|
||||
return undefined;
|
||||
}
|
||||
let parent = node && node.parentElement;
|
||||
let nonEditableElement;
|
||||
while (parent && parent !== parentLimit) {
|
||||
while (parent && (!parentLimit || parent !== parentLimit)) {
|
||||
if (!parent.isContentEditable) {
|
||||
nonEditableElement = parent;
|
||||
}
|
||||
if (parent.oid === "root") {
|
||||
break;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
return nonEditableElement;
|
||||
|
||||
Reference in New Issue
Block a user