From 7749fd3b968c7e0ba9af4b32c1adf06a4508f7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 20 Nov 2019 10:43:46 +0100 Subject: [PATCH] [FIX] component: remove stale fiber in scheduler Owl takes care of not rendering a component that will be unmounted immediately after, and it works. However, it also should clean up the newly added fiber. --- src/component/component.ts | 1 + tests/component/component.test.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/component/component.ts b/src/component/component.ts index 34e73de3..1a272efe 100644 --- a/src/component/component.ts +++ b/src/component/component.ts @@ -340,6 +340,7 @@ export class Component { // we were mounted when render was called, but we aren't anymore, so we // were actually about to be unmounted ; we can thus forget about this // fiber + fiber.isCompleted = true; __owl__.currentFiber = null; } }); diff --git a/tests/component/component.test.ts b/tests/component/component.test.ts index b41e015b..a8b100ad 100644 --- a/tests/component/component.test.ts +++ b/tests/component/component.test.ts @@ -5052,6 +5052,8 @@ describe("unmounting and remounting", () => { await nextTick(); // wait for changes to be detected before remounting await widget.mount(fixture); expect(fixture.innerHTML).toBe("
3
"); + // we want to make sure that there are no remaining tasks left at this point. + expect(Component.scheduler.tasks.length).toBe(0); }); test("sub component is still active after being unmounted and remounted", async () => {