From a466f0a5cb2f17d9b477d5e57ee937ffd423ec8e Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 20 Nov 2023 14:04:25 +0100 Subject: [PATCH] [FIX] web_editor: also check getComputedStyle in isBlock if other doc There was a condition in the `isBlock` util meant to bypass `getComputedStyle` in the case that a node was not in the DOM. Rather than doing that however, it was bypassing it in every case where the node was in a document that was different from that of the window. closes odoo/odoo#142803 X-original-commit: 04a9e97603806cb21cd90d991c0f94a225c326c5 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/editor/odoo-editor/src/utils/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js index 0df11e86dea..dbf52cbef9f 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js @@ -1242,13 +1242,13 @@ export function isBlock(node) { return false; } // The node might not be in the DOM, in which case it has no CSS values. - if (window.document !== node.ownerDocument) { + if (!node.isConnected) { return blockTagNames.includes(tagName); } // We won't call `getComputedStyle` more than once per node. let style = computedStyles.get(node); if (!style) { - style = window.getComputedStyle(node); + style = node.ownerDocument.defaultView.getComputedStyle(node); computedStyles.set(node, style); } if (style.display) {