From c31b53465476eb5e27b9d5e35f39cda8ed396cf4 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 20 Dec 2023 13:54:12 +0100 Subject: [PATCH] [REF] website: make mutation processing more robust This probably does not change much but it short-circuit a bunch of code when we click outside of an editable zone and something in the DOM happens. Allows for easier debugging of mutations. It also avoids the creation of a jQuery object when the mutation is about changing a contenteditable attribute, I guess any small perf improvement should be welcomed. Related to runbot-18747 X-original-commit: f93a2da57e1424898fbf6e157945e2afa97be89e Part-of: odoo/odoo#148728 --- .../src/components/wysiwyg_adapter/wysiwyg_adapter.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js index c5f81257252..ae22271b415 100644 --- a/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js +++ b/addons/website/static/src/components/wysiwyg_adapter/wysiwyg_adapter.js @@ -398,11 +398,17 @@ export class WysiwygAdapterComponent extends Wysiwyg { // generated a new stack and break the "redo" of the editor. this.odooEditor.automaticStepSkipStack(); for (const record of records) { - const $savable = $(record.target).closest(this.savableSelector); - if (record.attributeName === 'contenteditable') { continue; } + + const $savable = $(record.target).closest(this.savableSelector); + if (!$savable.length) { + continue; + } + + // Mark any savable element dirty if any tracked mutation occurs + // inside of it. $savable.not('.o_dirty').each(function () { if (!this.hasAttribute('data-oe-readonly')) { this.classList.add('o_dirty');