diff options
| author | Pierre Paridans <app@odoo.com> | 2019-03-27 13:50:22 +0000 |
|---|---|---|
| committer | Pierre Paridans <app@odoo.com> | 2019-05-23 15:41:30 +0000 |
| commit | 71a2d7c06a6142bfe3e967aa8ff60552e24eb0c1 (patch) | |
| tree | 82ce8a7bc574c7bf8a443d702a42fa6f11568898 /addons/web/static/tests | |
| parent | e5c65b22ab6bf7caabd7b8923949d687b61a01a7 (diff) | |
[REF] web: don't destroy twice a widget's children
Widget class indirectly inherits from ParentedMixin (through
PropertiesMixin).
The Widget's children are destroyed in both the ParentedMixin and the
Widget's own destroy() method.
This commit prevents from trying to destroy already destroyed children
and specifically from looping again on those children (resulting into a
minor performance improvement).
closes odoo/odoo#32174
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
| -rw-r--r-- | addons/web/static/tests/core/widget_tests.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/web/static/tests/core/widget_tests.js b/addons/web/static/tests/core/widget_tests.js index 440cc97b524..13515e08641 100644 --- a/addons/web/static/tests/core/widget_tests.js +++ b/addons/web/static/tests/core/widget_tests.js @@ -468,6 +468,20 @@ QUnit.module('core', {}, function () { slowWillStartPromise.resolve(); }); + QUnit.test("don't destroy twice widget's children", function (assert) { + assert.expect(2); + + var parent = new Widget(); + var child = new (Widget.extend({ + destroy: function () { + assert.step('destroy'); + } + }))(parent); + + parent.destroy(); + assert.verifySteps(['destroy'], "child should have been detroyed only once"); + }); + }); }); |
