[IMP] compiler: scope generated ids to their prefix

This means that unrelated ids (eg the id of a template, variable or key)
not longer share the same incrementing counter, meaning that you no
longer see a variable named "v2" unless another variable "v1" was
generated previously, this is also true for block data.
This commit is contained in:
Samuel Degueldre
2021-12-22 12:33:17 +01:00
committed by Aaron Bohy
parent c7af885f43
commit 9f2e2bcc66
32 changed files with 595 additions and 590 deletions
@@ -78,8 +78,8 @@ exports[`basics can be clicked on and updated 1`] = `
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['state'].counter;
const v1 = ctx['state'];
let hdlr2 = [()=>v1.counter++, ctx];
return block1([txt1, hdlr2]);
let hdlr1 = [()=>v1.counter++, ctx];
return block1([txt1, hdlr1]);
}
}"
`;
@@ -117,10 +117,10 @@ exports[`basics can inject values in tagged templates 1`] = `
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { getTemplate } = helpers;
const callTemplate_2 = getTemplate(\`__template__999\`);
const callTemplate_1 = getTemplate(\`__template__999\`);
return function template(ctx, node, key = \\"\\") {
return callTemplate_2.call(this, ctx, node, key + \`__1\`);
return callTemplate_1.call(this, ctx, node, key + \`__1\`);
}
}"
`;
@@ -455,8 +455,8 @@ exports[`basics reconciliation alg is not confused in some specific situation 1`
return function template(ctx, node, key = \\"\\") {
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
const tKey_2 = 4;
let b3 = toggler(tKey_2, component(\`Child\`, {}, tKey_2 + key + \`__3\`, node, ctx));
const tKey_1 = 4;
let b3 = toggler(tKey_1, component(\`Child\`, {}, tKey_1 + key + \`__2\`, node, ctx));
return block1([], [b2, b3]);
}
}"
@@ -496,8 +496,8 @@ exports[`basics rerendering a widget with a sub widget 2`] = `
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['state'].counter;
const v1 = ctx['state'];
let hdlr2 = [()=>v1.counter++, ctx];
return block1([txt1, hdlr2]);
let hdlr1 = [()=>v1.counter++, ctx];
return block1([txt1, hdlr1]);
}
}"
`;
@@ -511,9 +511,9 @@ exports[`basics same t-keys in two different places 1`] = `
return function template(ctx, node, key = \\"\\") {
const tKey_1 = 1;
let b2 = toggler(tKey_1, component(\`Child\`, {blip: '1'}, tKey_1 + key + \`__2\`, node, ctx));
const tKey_3 = 1;
let b3 = toggler(tKey_3, component(\`Child\`, {blip: '2'}, tKey_3 + key + \`__4\`, node, ctx));
let b2 = toggler(tKey_1, component(\`Child\`, {blip: '1'}, tKey_1 + key + \`__1\`, node, ctx));
const tKey_2 = 1;
let b3 = toggler(tKey_2, component(\`Child\`, {blip: '2'}, tKey_2 + key + \`__2\`, node, ctx));
return block1([], [b2, b3]);
}
}"
@@ -753,9 +753,9 @@ exports[`basics t-key on a component with t-if, and a sibling component 1`] = `
let b2,b3;
if (false) {
const tKey_1 = 'str';
b2 = toggler(tKey_1, component(\`Child\`, {}, tKey_1 + key + \`__2\`, node, ctx));
b2 = toggler(tKey_1, component(\`Child\`, {}, tKey_1 + key + \`__1\`, node, ctx));
}
b3 = component(\`Child\`, {}, key + \`__3\`, node, ctx);
b3 = component(\`Child\`, {}, key + \`__2\`, node, ctx);
return block1([], [b2, b3]);
}
}"
@@ -875,7 +875,7 @@ exports[`basics update props of component without concrete own node 1`] = `
return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['childProps'].key;
let b2 = toggler(tKey_1, component(\`Child\`, ctx['childProps'], tKey_1 + key + \`__2\`, node, ctx));
let b2 = toggler(tKey_1, component(\`Child\`, ctx['childProps'], tKey_1 + key + \`__1\`, node, ctx));
return block1([], [b2]);
}
}"
@@ -888,7 +888,7 @@ exports[`basics update props of component without concrete own node 2`] = `
return function template(ctx, node, key = \\"\\") {
const tKey_1 = ctx['props'].subKey;
return toggler(tKey_1, component(\`Custom\`, {key: ctx['props'].key,subKey: ctx['props'].subKey}, tKey_1 + key + \`__2\`, node, ctx));
return toggler(tKey_1, component(\`Custom\`, {key: ctx['props'].key,subKey: ctx['props'].subKey}, tKey_1 + key + \`__1\`, node, ctx));
}
}"
`;