[FIX] compiler, component: handle change of t-key before patch

Have a dynamic children with a t-key. This child has a delayed willStart.
Change the key during a rendering.

Before this commit there was a leak: a component corresponding to an old key had been created, xwithout being destroyed.

After this commit, the outdated component is destroyed.
This commit is contained in:
Lucas Perais (lpe)
2022-01-10 19:32:49 +01:00
parent a568ca6687
commit b9f5a9aa47
27 changed files with 547 additions and 445 deletions
@@ -6,7 +6,7 @@ exports[`basics basic use 1`] = `
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {p: 1}, key + \`__1\`, node, ctx);
return component(\`Child\`, {p: 1}, key+\`__1\`,null, node, ctx);
}
}"
`;
@@ -33,10 +33,10 @@ exports[`basics can select a sub widget 1`] = `
return function template(ctx, node, key = \\"\\") {
let b2,b3;
if (ctx['env'].options.flag) {
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
b2 = component(\`Child\`, {}, key+\`__1\`,null, node, ctx);
}
if (!ctx['env'].options.flag) {
b3 = component(\`OtherChild\`, {}, key + \`__2\`, node, ctx);
b3 = component(\`OtherChild\`, {}, key+\`__2\`,null, node, ctx);
}
return multi([b2, b3]);
}
@@ -77,10 +77,10 @@ exports[`basics can select a sub widget, part 2 1`] = `
return function template(ctx, node, key = \\"\\") {
let b2,b3;
if (ctx['state'].flag) {
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
b2 = component(\`Child\`, {}, key+\`__1\`,null, node, ctx);
}
if (!ctx['state'].flag) {
b3 = component(\`OtherChild\`, {}, key + \`__2\`, node, ctx);
b3 = component(\`OtherChild\`, {}, key+\`__2\`,null, node, ctx);
}
return multi([b2, b3]);
}
@@ -119,7 +119,7 @@ exports[`basics sub widget is interactive 1`] = `
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {p: 1}, key + \`__1\`, node, ctx);
return component(\`Child\`, {p: 1}, key+\`__1\`,null, node, ctx);
}
}"
`;
@@ -147,7 +147,7 @@ exports[`basics top level sub widget with a parent 1`] = `
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2 = component(\`ComponentB\`, {}, key + \`__1\`, node, ctx);
let b2 = component(\`ComponentB\`, {}, key+\`__1\`,null, node, ctx);
return block1([], [b2]);
}
}"
@@ -159,7 +159,7 @@ exports[`basics top level sub widget with a parent 2`] = `
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`ComponentC\`, {}, key + \`__1\`, node, ctx);
return component(\`ComponentC\`, {}, key+\`__1\`,null, node, ctx);
}
}"
`;