[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:
Aaron Bohy
2019-11-20 13:19:14 +01:00
committed by Géry Debongnie
parent 28ee790b3e
commit 2e3e8cd603
9 changed files with 86 additions and 45 deletions
+1 -4
View File
@@ -257,13 +257,12 @@ describe("Context", () => {
test("destroyed component before being mounted is inactive", async () => {
const testContext = new Context({ a: 123 });
const def = makeDeferred();
class Child extends Component<any, any> {
static template = xml`<span><t t-esc="contextObj.a"/></span>`;
contextObj = useContext(testContext);
willStart() {
return def;
return makeDeferred();
}
}
class Parent extends Component<any, any> {
@@ -279,8 +278,6 @@ describe("Context", () => {
parent.state.flag = false;
await prom;
expect(fixture.innerHTML).toBe("<div></div>");
def.resolve(); // must wait for willStart promise to be resolved
await nextTick();
// kind of whitebox...
// we make sure we do not have any pending subscriptions to the 'update'
// event