From f02b15dcc2c036932b2fd1fe52db9141a81fa2d6 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 20 Jan 2022 12:24:26 +0000 Subject: [PATCH] [FIX] web_editor: restore rules cache This commit restores the cache on the document that was lost with the new parsing system [1]. It allows for faster convertion to inline styles after the first time on the same document. [1] https://github.com/odoo/odoo/commit/10e749537186dfb80aee1f2537f3b5804f66cfe5#diff-5922d38ff6520249ff5b3a3240eebc350c6f9f4d9f486d512128c23261c45841L19 closes odoo/odoo#83139 X-original-commit: 0ee96727793cfa64c9cdb9f3ef3b7e6b1ef1f631 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/backend/convert_inline.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/backend/convert_inline.js b/addons/web_editor/static/src/js/backend/convert_inline.js index 707a673b97a..323ab5f23ee 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -336,8 +336,11 @@ function classToStyle($editable, cssRules) { * specificity: number;}> */ function toInline($editable, cssRules) { + const doc = $editable[0].ownerDocument; + cssRules = cssRules || doc._rulesCache; if (!cssRules) { - cssRules = getCSSRules($editable[0].ownerDocument); + cssRules = getCSSRules(doc); + doc._rulesCache = cssRules; } // Fix outlook image rendering bug (this change will be kept in both