From 7c0b026487a03c3e039e808f16e0eccbe583b980 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 4 Jan 2022 14:13:17 +0000 Subject: [PATCH] [FIX] web_editor: remove divs created by default shadow computation The shadow option needs to create a div on the fly to be able to retrieve the default shadow value. This commit makes sure these divs are also removed when no longer needed. This also simplifies the code and actually avoids that div creation when it is not needed. task-2752326 closes odoo/odoo#84324 X-original-commit: 309f03c011fc8e5e0bec9882af54a8147025118f Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/editor/snippets.options.js | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index fa037627f3a..186698ff35a 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -4536,22 +4536,17 @@ registry.Box = SnippetOptionWidget.extend({ * @returns {string} */ _getDefaultShadow(type, shadowClass) { + if (!type) { + return 'none'; + } + const el = document.createElement('div'); - if (type) { - el.classList.add(shadowClass); - } + el.classList.add(shadowClass); document.body.appendChild(el); - switch (type) { - case 'outset': { - return $(el).css('box-shadow'); - } - case 'inset': { - return $(el).css('box-shadow') + ' inset'; - } - } + const shadow = `${$(el).css('box-shadow')}${type === 'inset' ? ' inset' : ''}`; el.remove(); - return 'none'; - } + return shadow; + }, });