diff options
| author | Aaron Bohy <aab@odoo.com> | 2020-04-24 07:14:24 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-04-24 09:17:57 +0000 |
| commit | 797403c0a9e6c7c0b23dbe04b050d59821b2953c (patch) | |
| tree | 33214a760bc9c084d9ddf4f3ac424f22f7b2eb14 /addons/web/static/src/js/views/basic/basic_renderer.js | |
| parent | e6a1e240f18bbc95475cd82154bb91a455704b15 (diff) | |
[FIX] web: list: don't call mounted twice on fields
Before this commit, when a list contained owl field components,
the mounted hook was called twice on those components. This may
cause tricky issues like handlers being bound twice, and memory
leaks.
closes odoo/odoo#50127
X-original-commit: 206dd91e78f7896fc6b01020507657e61771787f
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_renderer.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js index 1db59bbab41..3d5c14e0b10 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -11,6 +11,7 @@ var AbstractRenderer = require('web.AbstractRenderer'); var config = require('web.config'); var core = require('web.core'); var dom = require('web.dom'); +const utils = require('web.utils'); var widgetRegistry = require('web.widget_registry'); const { WidgetAdapterMixin } = require('web.OwlCompatibility'); @@ -49,26 +50,30 @@ var BasicRenderer = AbstractRenderer.extend(WidgetAdapterMixin, { * Called each time the renderer is attached into the DOM. */ on_attach_callback: function () { + // call on_attach_callback on field widgets for (const handle in this.allFieldWidgets) { this.allFieldWidgets[handle].forEach(widget => { - if (widget.on_attach_callback) { + if (!utils.isComponent(widget.constructor) && widget.on_attach_callback) { widget.on_attach_callback(); } }); } + // call on_attach_callback on child components (including field components) WidgetAdapterMixin.on_attach_callback.call(this); }, /** * Called each time the renderer is detached from the DOM. */ on_detach_callback: function () { + // call on_detach_callback on field widgets for (const handle in this.allFieldWidgets) { this.allFieldWidgets[handle].forEach(widget => { - if (widget.on_detach_callback) { + if (!utils.isComponent(widget.constructor) && widget.on_detach_callback) { widget.on_detach_callback(); } }); } + // call on_detach_callback on child components (including field components) WidgetAdapterMixin.on_detach_callback.call(this); }, |
