mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: destroy not yet mounted components (2)
Following 2922cee6ea
Previous commit was not correct: used children with a cancelled
fiber (for instance, with a new currentFiber) could be destroyed.
This commit fixes the issue differently, by directly detecting
children that are not used anymore (and not mounted), and destroy
them directly (no need to wait for willStart promise to be resolved
anymore).
This commit is contained in:
committed by
Géry Debongnie
parent
28ee790b3e
commit
2e3e8cd603
@@ -977,13 +977,12 @@ describe("destroy method", () => {
|
||||
});
|
||||
|
||||
test("destroying a widget before being mounted (2)", async () => {
|
||||
const def = makeDeferred();
|
||||
const steps: string[] = [];
|
||||
class Child extends Component<any, any> {
|
||||
static template = xml`<span></span>`;
|
||||
willStart() {
|
||||
steps.push("willStart");
|
||||
return def;
|
||||
return makeDeferred();
|
||||
}
|
||||
__destroy(parent) {
|
||||
steps.push("__destroy");
|
||||
@@ -1002,12 +1001,6 @@ describe("destroy method", () => {
|
||||
parent.state.flag = false;
|
||||
await prom;
|
||||
expect(fixture.innerHTML).toBe("<div></div>");
|
||||
// we can't easily detect that we have to destroy the component before
|
||||
// willStart is resolved. However, willStart should have no side-effect
|
||||
// (like dispatching an action), so it's probably fine
|
||||
expect(steps).toEqual(["willStart"]);
|
||||
def.resolve();
|
||||
await nextTick();
|
||||
expect(steps).toEqual(["willStart", "__destroy"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user