[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
@@ -48,7 +48,7 @@ exports[`t-call dynamic t-call: key is propagated 1`] = `
let { call } = helpers;
return function template(ctx, node, key = \\"\\") {
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
let b2 = component(\`Child\`, {}, key+\`__1\`,null, node, ctx);
const template1 = (ctx['sub']);
let b3 = call(this, template1, ctx, node, key + \`__2\`);
return multi([b2, b3]);
@@ -76,7 +76,7 @@ exports[`t-call dynamic t-call: key is propagated 3`] = `
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
return component(\`Child\`, {}, key+\`__1\`,null, node, ctx);
}
}"
`;
@@ -196,7 +196,7 @@ exports[`t-call parent is set within t-call 2`] = `
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
return component(\`Child\`, {}, key+\`__1\`,null, node, ctx);
}
}"
`;
@@ -233,7 +233,7 @@ exports[`t-call parent is set within t-call with no parentNode 2`] = `
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
return component(\`Child\`, {}, key+\`__1\`,null, node, ctx);
}
}"
`;
@@ -280,7 +280,7 @@ exports[`t-call sub components in two t-calls 2`] = `
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {val: ctx['state'].val}, key + \`__1\`, node, ctx);
return component(\`Child\`, {val: ctx['state'].val}, key+\`__1\`,null, node, ctx);
}
}"
`;
@@ -332,7 +332,7 @@ exports[`t-call t-call in t-foreach and children component 2`] = `
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {val: ctx['val']}, key + \`__1\`, node, ctx);
return component(\`Child\`, {val: ctx['val']}, key+\`__1\`,null, node, ctx);
}
}"
`;