[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) <qsm@odoo.com>
This commit is contained in:
Louis (loco)
2023-02-19 04:11:12 +01:00
committed by qsm-odoo
parent c037fe9b79
commit 4e664c9396
@@ -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
*/