[FIX] web_editor: don't crash if anchorNode is Reserved.

When on Firefox, with sale_product_matrix and sale_quotation_builder installed,
clicking anywhere on the matrix (after opening it) raises a traceback.

It is due to the fact that isBody tries to access anchorNode.nodeName, which
is unexpectedly unaccessible as anchorNode is {Reserved}.

Due to the absence of clear documentation of the possible reasons of this problem,
it was decided to reuse the existing fallback on 'return null', which avoids the
traceback.

closes odoo/odoo#38277

X-original-commit: 70c484e72bffc9ab759df3c376ad9157acec3965
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Feyens
2019-10-09 12:19:46 +00:00
committed by fw-bot
parent badd0c0bb2
commit cfe06f6d68
@@ -660,9 +660,15 @@ define([
var selection = document.getSelection();
if (!selection || selection.rangeCount === 0) {
return null;
} else if (dom.isBody(selection.anchorNode)) {
// Firefox: returns entire body as range on initialization. We won't never need it.
return null;
} else {
try {
if (dom.isBody(selection.anchorNode)) {
// Firefox: returns entire body as range on initialization. We won't never need it.
return null;
}
} catch (e) {
return null;
}
}
var nativeRng = selection.getRangeAt(0);