summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/widgets
diff options
context:
space:
mode:
authorJulien Castiaux <juc@odoo.com>2019-05-08 14:07:55 +0000
committerJulien Castiaux <juc@odoo.com>2019-05-09 13:53:22 +0000
commit538f99ccce90cb1487bd19e38b4bc8310b0677f6 (patch)
treedec4eda1f9c00e57a8ebad3c59e7116181529bea /addons/web_editor/static/src/js/widgets
parente11bacfe512a3170f44d6d43646af914a9cf3b73 (diff)
[FIX] web_editor: restoreRange on invalid node
In a web editor, add some text, select the text, add a link and immediately discard the link modal. Traceback. The traceback is a DOM `IndexSizeError`, that error is thrown when the boundaries of a DOM Range (`document.createRange`) are outside of the ranged elements. In this context, the error happens because the element is empty and the range has an end bound set to the size of the selected text. Odoo wrap code does some text node split in order to attach the link just on the selected text. If it correctly re-set the underlying structure, it does not update the $(editable) structure used to restore ranges. opw-1981751 closes odoo/odoo#33257 Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
Diffstat (limited to 'addons/web_editor/static/src/js/widgets')
-rw-r--r--addons/web_editor/static/src/js/widgets/widgets.js1
1 files changed, 1 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js
index 7fda9238f34..43bc2e95199 100644
--- a/addons/web_editor/static/src/js/widgets/widgets.js
+++ b/addons/web_editor/static/src/js/widgets/widgets.js
@@ -1405,6 +1405,7 @@ var LinkDialog = Dialog.extend({
}
this.data.range = range.create(sc, so, ec, eo);
+ $(editable).data("range", this.data.range);
this.data.range.select();
} else {
nodes = dom.ancestor(sc, dom.isAnchor).childNodes;