diff --git a/tests/components/__snapshots__/basics.test.ts.snap b/tests/components/__snapshots__/basics.test.ts.snap
index 9b905ca9..6e341a6d 100644
--- a/tests/components/__snapshots__/basics.test.ts.snap
+++ b/tests/components/__snapshots__/basics.test.ts.snap
@@ -265,6 +265,59 @@ exports[`basics class parent, class child component with props 2`] = `
}"
`;
+exports[`basics component children doesn't leak (if case) 1`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
+
+ return function template(ctx, node, key = \\"\\") {
+ let b2;
+ if (ctx['ifVar']) {
+ b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
+ }
+ return multi([b2]);
+ }
+}"
+`;
+
+exports[`basics component children doesn't leak (if case) 2`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
+
+ let block1 = createBlock(\`
\`);
+
+ return function template(ctx, node, key = \\"\\") {
+ return block1();
+ }
+}"
+`;
+
+exports[`basics component children doesn't leak (t-key case) 1`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
+
+ return function template(ctx, node, key = \\"\\") {
+ const tKey_1 = ctx['keyVar'];
+ return toggler(tKey_1, component(\`Child\`, {}, tKey_1 + key + \`__1\`, node, ctx));
+ }
+}"
+`;
+
+exports[`basics component children doesn't leak (t-key case) 2`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
+
+ let block1 = createBlock(\`\`);
+
+ return function template(ctx, node, key = \\"\\") {
+ return block1();
+ }
+}"
+`;
+
exports[`basics component with dynamic content can be updated 1`] = `
"function anonymous(bdom, helpers
) {
diff --git a/tests/components/basics.test.ts b/tests/components/basics.test.ts
index 62bfd1db..2bd67aaf 100644
--- a/tests/components/basics.test.ts
+++ b/tests/components/basics.test.ts
@@ -794,6 +794,75 @@ describe("basics", () => {
await nextTick();
expect(fixture.textContent!.trim()).toBe("2__3");
});
+
+ test("component children doesn't leak (if case)", async () => {
+ class Child extends Component {
+ static template = xml``;
+ setup() {
+ useLogLifecycle();
+ }
+ }
+ class Parent extends Component {
+ static components = { Child };
+ static template = xml``;
+ ifVar = true;
+ }
+
+ const parent = await mount(Parent, fixture);
+ expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
+ expect([
+ "Child:setup",
+ "Child:willStart",
+ "Child:willRender",
+ "Child:rendered",
+ "Child:mounted",
+ ]).toBeLogged();
+
+ parent.ifVar = false;
+ parent.render();
+ await nextTick();
+ expect(Object.keys(parent.__owl__.children).length).toStrictEqual(0);
+ expect(["Child:willUnmount", "Child:willDestroy"]).toBeLogged();
+ });
+
+ test("component children doesn't leak (t-key case)", async () => {
+ // This test should encompass the t-foreach and t-call cases too (because they also use a flavor of some key)
+ class Child extends Component {
+ static template = xml``;
+ setup() {
+ useLogLifecycle();
+ }
+ }
+ class Parent extends Component {
+ static components = { Child };
+ static template = xml``;
+ keyVar = 1;
+ }
+
+ const parent = await mount(Parent, fixture);
+ expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
+ expect([
+ "Child:setup",
+ "Child:willStart",
+ "Child:willRender",
+ "Child:rendered",
+ "Child:mounted",
+ ]).toBeLogged();
+
+ parent.keyVar = 2;
+ parent.render();
+ await nextTick();
+ expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
+ expect([
+ "Child:setup",
+ "Child:willStart",
+ "Child:willRender",
+ "Child:rendered",
+ "Child:willUnmount",
+ "Child:willDestroy",
+ "Child:mounted",
+ ]).toBeLogged();
+ });
});
describe("mount targets", () => {
@@ -900,73 +969,4 @@ describe("t-out in components", () => {
"<b>one</b>one<b>two</b>two<b>tree</b>tree
"
);
});
-
- test("component children doesn't leak (if case)", async () => {
- class Child extends Component {
- static template = xml``;
- setup() {
- useLogLifecycle();
- }
- }
- class Parent extends Component {
- static components = { Child };
- static template = xml``;
- ifVar = true;
- }
-
- const parent = await mount(Parent, fixture);
- expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
- expect([
- "Child:setup",
- "Child:willStart",
- "Child:willRender",
- "Child:rendered",
- "Child:mounted",
- ]).toBeLogged();
-
- parent.ifVar = false;
- parent.render();
- await nextTick();
- expect(Object.keys(parent.__owl__.children).length).toStrictEqual(0);
- expect(["Child:willUnmount", "Child:willDestroy"]).toBeLogged();
- });
-
- test("component children doesn't leak (t-key case)", async () => {
- // This test should encompass the t-foreach and t-call cases too (because they also use a flavor of some key)
- class Child extends Component {
- static template = xml``;
- setup() {
- useLogLifecycle();
- }
- }
- class Parent extends Component {
- static components = { Child };
- static template = xml``;
- keyVar = 1;
- }
-
- const parent = await mount(Parent, fixture);
- expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
- expect([
- "Child:setup",
- "Child:willStart",
- "Child:willRender",
- "Child:rendered",
- "Child:mounted",
- ]).toBeLogged();
-
- parent.keyVar = 2;
- parent.render();
- await nextTick();
- expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
- expect([
- "Child:setup",
- "Child:willStart",
- "Child:willRender",
- "Child:rendered",
- "Child:willUnmount",
- "Child:willDestroy",
- "Child:mounted",
- ]).toBeLogged();
- });
});