[FIX] web: remove memory leak with bootstrap tooltips

This commit fixes a memory leak occurring in basic renderers. It
seems that the issue comes from bootstrap 5.1 (might be fixed in
5.2). As this is legacy code, and updating from 5.1 to 5.2 doesn't
seem easy (moreover in stable), we come with a simple and local
patch in BasicRenderer.

X-original-commit: 3c01b1cd77adec146b1a90f96bb1223a2108678b
Part-of: odoo/odoo#108620
Co-authored-by: Samuel Degueldre <sad@odoo.com>
This commit is contained in:
Aaron Bohy
2022-12-23 19:19:14 +01:00
co-authored by Samuel Degueldre
parent 911fb327b6
commit a39e703a2e
@@ -47,11 +47,19 @@ var BasicRenderer = AbstractRenderer.extend(WidgetAdapterMixin, {
// and on which field it is set.
this.handleField = null;
this.viewEditable = params.viewEditable;
// There an issue with bootstrap 5.1 (probably fixed in 5.2). A reference
// to some nodes with attached tooltips are kept and can never be garbage collected.
// We thus manually dispose them at destroy.
this.jQueryNodesWithTooltip = [];
},
/**
* @override
*/
destroy: function () {
for (const $node of this.jQueryNodesWithTooltip) {
$node.tooltip("dispose");
}
this._super.apply(this, arguments);
WidgetAdapterMixin.destroy.call(this);
},
@@ -315,6 +323,8 @@ var BasicRenderer = AbstractRenderer.extend(WidgetAdapterMixin, {
// widget's $el
$node = $node.length ? $node : widget.$el;
$node.tooltip(this._getTooltipOptions(widget));
this.jQueryNodesWithTooltip.push($node);
},
/**
* Does the necessary DOM updates to match the given modifiers data. The