From 4e664c939655f1cb04ebfbd7bd7c72ab2beb26d6 Mon Sep 17 00:00:00 2001 From: "Louis (loco)" Date: Fri, 17 Feb 2023 09:00:52 +0000 Subject: [PATCH] [FIX] website: disconnect the observer before destroy the TOC snippet A DOM observer is initialized at the start of the table of content (TOC) snippet options but is never disconnected. This could lead to memory leak. The goal of this commit is to disconnect this observer and stop intercepting the changes of the DOM at the destroy of the snippet option. Related PR: https://github.com/odoo/odoo/pull/110860 closes odoo/odoo#113075 X-original-commit: 3787599479d2f1e951bca6622c7049b62d631795 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/snippets/s_table_of_content/options.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/website/static/src/snippets/s_table_of_content/options.js b/addons/website/static/src/snippets/s_table_of_content/options.js index caa09ff3224..937366c59cf 100644 --- a/addons/website/static/src/snippets/s_table_of_content/options.js +++ b/addons/website/static/src/snippets/s_table_of_content/options.js @@ -20,6 +20,14 @@ options.registry.TableOfContent = options.Class.extend({ this.observer.observe(targetNode, config); return this._super(...arguments); }, + /** + * @override + */ + destroy: function () { + // The observer needs to be disconnected first. + this.observer.disconnect(); + this._super(...arguments); + }, /** * @override */