From cfe06f6d6841d49f1293f0514ba159920171c2b0 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Mon, 7 Oct 2019 09:48:14 +0000 Subject: [PATCH] [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) --- .../static/lib/summernote/src/js/core/range.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/lib/summernote/src/js/core/range.js b/addons/web_editor/static/lib/summernote/src/js/core/range.js index 5c2dbe3b32c..20556b1d4fb 100644 --- a/addons/web_editor/static/lib/summernote/src/js/core/range.js +++ b/addons/web_editor/static/lib/summernote/src/js/core/range.js @@ -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);