[IMP] compiler: improve generated compiled code

This commit is contained in:
Géry Debongnie
2021-12-22 11:33:12 +01:00
parent d160c4a628
commit e8b0f31da6
36 changed files with 939 additions and 936 deletions
@@ -110,11 +110,11 @@ exports[`slots can define and call slots with params 2`] = `
let block1 = createBlock(\`<div><block-text-0/><div><block-child-0/></div><block-text-1/><div><block-child-1/></div></div>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['props'].slots['header'].param;
let txt1 = ctx['props'].slots['header'].param;
let b2 = callSlot(ctx, node, key, 'header', false, {});
let d2 = ctx['props'].slots['footer'].param;
let txt2 = ctx['props'].slots['footer'].param;
let b3 = callSlot(ctx, node, key, 'footer', false, {});
return block1([d1, d2], [b2, b3]);
return block1([txt1, txt2], [b2, b3]);
}
}"
`;
@@ -522,10 +522,10 @@ exports[`slots dynamic t-slot call 2`] = `
let block1 = createBlock(\`<button block-handler-0=\\"click\\"><block-child-0/></button>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = [ctx['toggle'], ctx];
let hdlr1 = [ctx['toggle'], ctx];
const slot1 = (ctx['current'].slot);
let b2 = toggler(slot1, callSlot(ctx, node, key, slot1), true, {});
return block1([d1], [b2]);
return block1([hdlr1], [b2]);
}
}"
`;
@@ -572,9 +572,9 @@ exports[`slots dynamic t-slot call with default 2`] = `
}
return function template(ctx, node, key = \\"\\") {
let d1 = [ctx['toggle'], ctx];
let hdlr1 = [ctx['toggle'], ctx];
let b3 = callSlot(ctx, node, key, (ctx['current'].slot), true, {}, defaultContent1);
return block1([d1], [b3]);
return block1([hdlr1], [b3]);
}
}"
`;
@@ -759,8 +759,8 @@ exports[`slots multiple slots containing components 3`] = `
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['props'].val;
return block1([d1]);
let txt1 = ctx['props'].val;
return block1([txt1]);
}
}"
`;
@@ -776,8 +776,8 @@ exports[`slots named slot inside slot 1`] = `
let block3 = createBlock(\`<p>B<block-text-0/></p>\`);
function slot2(ctx, node, key = \\"\\") {
let d1 = ctx['value'];
return block2([d1]);
let txt1 = ctx['value'];
return block2([txt1]);
}
function slot3(ctx, node, key = \\"\\") {
@@ -786,8 +786,8 @@ exports[`slots named slot inside slot 1`] = `
}
function slot5(ctx, node, key = \\"\\") {
let d2 = ctx['value'];
return block3([d2]);
let txt2 = ctx['value'];
return block3([txt2]);
}
return function template(ctx, node, key = \\"\\") {
@@ -825,8 +825,8 @@ exports[`slots named slot inside slot, part 3 1`] = `
let block3 = createBlock(\`<p>B<block-text-0/></p>\`);
function slot2(ctx, node, key = \\"\\") {
let d1 = ctx['value'];
return block2([d1]);
let txt1 = ctx['value'];
return block2([txt1]);
}
function slot3(ctx, node, key = \\"\\") {
@@ -835,8 +835,8 @@ exports[`slots named slot inside slot, part 3 1`] = `
}
function slot5(ctx, node, key = \\"\\") {
let d2 = ctx['value'];
return block3([d2]);
let txt2 = ctx['value'];
return block3([txt2]);
}
return function template(ctx, node, key = \\"\\") {
@@ -907,8 +907,8 @@ exports[`slots named slots inside slot, again 1`] = `
let block3 = createBlock(\`<p>B<block-text-0/></p>\`);
function slot2(ctx, node, key = \\"\\") {
let d1 = ctx['value'];
return block2([d1]);
let txt1 = ctx['value'];
return block2([txt1]);
}
function slot3(ctx, node, key = \\"\\") {
@@ -917,8 +917,8 @@ exports[`slots named slots inside slot, again 1`] = `
}
function slot5(ctx, node, key = \\"\\") {
let d2 = ctx['value'];
return block3([d2]);
let txt2 = ctx['value'];
return block3([txt2]);
}
return function template(ctx, node, key = \\"\\") {
@@ -1073,8 +1073,8 @@ exports[`slots nested slots: evaluation context and parented relationship 4`] =
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['props'].val;
return block1([d1]);
let txt1 = ctx['props'].val;
return block1([txt1]);
}
}"
`;
@@ -1379,10 +1379,10 @@ exports[`slots slot are properly rendered if inner props are changed 1`] = `
}
return function template(ctx, node, key = \\"\\") {
let d1 = [ctx['inc'], ctx];
let d2 = ctx['state'].val;
let hdlr1 = [ctx['inc'], ctx];
let txt2 = ctx['state'].val;
let b3 = component(\`GenericComponent\`, {slots: {'default': {__render: slot1, __ctx: ctx}}}, key + \`__3\`, node, ctx);
return block1([d1, d2], [b3]);
return block1([hdlr1, txt2], [b3]);
}
}"
`;
@@ -1410,8 +1410,8 @@ exports[`slots slot are properly rendered if inner props are changed 3`] = `
let block1 = createBlock(\`<div> SC:<block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['props'].val;
return block1([d1]);
let txt1 = ctx['props'].val;
return block1([txt1]);
}
}"
`;
@@ -1428,8 +1428,8 @@ exports[`slots slot content is bound to caller (variation) 1`] = `
ctx = Object.create(ctx);
ctx[isBoundary] = 1
setContextValue(ctx, \\"var\\", 1);
let d1 = [()=>this.inc(), ctx];
return block1([d1]);
let hdlr1 = [()=>this.inc(), ctx];
return block1([hdlr1]);
}
return function template(ctx, node, key = \\"\\") {
@@ -1462,8 +1462,8 @@ exports[`slots slot content is bound to caller 1`] = `
let block1 = createBlock(\`<button block-handler-0=\\"click\\">some text</button>\`);
function slot1(ctx, node, key = \\"\\") {
let d1 = [ctx['inc'], ctx];
return block1([d1]);
let hdlr1 = [ctx['inc'], ctx];
return block1([hdlr1]);
}
return function template(ctx, node, key = \\"\\") {
@@ -1636,9 +1636,9 @@ exports[`slots slots are properly bound to correct component 2`] = `
ctx = Object.create(ctx);
ctx[isBoundary] = 1
setContextValue(ctx, \\"var\\", 1);
let d1 = [()=>this.increment(), ctx];
let d2 = ctx['state'].value;
return block1([d1, d2]);
let hdlr1 = [()=>this.increment(), ctx];
let txt2 = ctx['state'].value;
return block1([hdlr1, txt2]);
}
return function template(ctx, node, key = \\"\\") {
@@ -1657,15 +1657,15 @@ exports[`slots slots are rendered with proper context 1`] = `
let block2 = createBlock(\`<button block-handler-0=\\"click\\">do something</button>\`);
function slot2(ctx, node, key = \\"\\") {
let d2 = [ctx['doSomething'], ctx];
return block2([d2]);
let hdlr2 = [ctx['doSomething'], ctx];
return block2([hdlr2]);
}
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['state'].val;
let txt1 = ctx['state'].val;
const ctx1 = capture(ctx);
let b3 = component(\`Dialog\`, {slots: {'footer': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx);
return block1([d1], [b3]);
return block1([txt1], [b3]);
}
}"
`;
@@ -1725,9 +1725,9 @@ exports[`slots slots are rendered with proper context, part 2 2`] = `
let block1 = createBlock(\`<a block-attribute-0=\\"href\\"><block-child-0/></a>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['props'].to;
let attr1 = ctx['props'].to;
let b2 = callSlot(ctx, node, key, 'default', false, {});
return block1([d1], [b2]);
return block1([attr1], [b2]);
}
}"
`;
@@ -1773,9 +1773,9 @@ exports[`slots slots are rendered with proper context, part 3 2`] = `
let block1 = createBlock(\`<a block-attribute-0=\\"href\\"><block-child-0/></a>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['props'].to;
let attr1 = ctx['props'].to;
let b2 = callSlot(ctx, node, key, 'default', false, {});
return block1([d1], [b2]);
return block1([attr1], [b2]);
}
}"
`;
@@ -1812,9 +1812,9 @@ exports[`slots slots are rendered with proper context, part 4 2`] = `
let block1 = createBlock(\`<a block-attribute-0=\\"href\\"><block-child-0/></a>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['props'].to;
let attr1 = ctx['props'].to;
let b2 = callSlot(ctx, node, key, 'default', false, {});
return block1([d1], [b2]);
return block1([attr1], [b2]);
}
}"
`;
@@ -1829,8 +1829,8 @@ exports[`slots slots in slots, with vars 1`] = `
let block2 = createBlock(\`<p>hey<block-text-0/></p>\`);
function slot2(ctx, node, key = \\"\\") {
let d1 = ctx['test'];
return block2([d1]);
let txt1 = ctx['test'];
return block2([txt1]);
}
return function template(ctx, node, key = \\"\\") {
@@ -1915,9 +1915,9 @@ exports[`slots slots in t-foreach and re-rendering 2`] = `
let block1 = createBlock(\`<span><block-text-0/><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['state'].val;
let txt1 = ctx['state'].val;
let b2 = callSlot(ctx, node, key, 'default', false, {});
return block1([d1], [b2]);
return block1([txt1], [b2]);
}
}"
`;
@@ -1934,8 +1934,8 @@ exports[`slots slots in t-foreach in t-foreach 1`] = `
let block7 = createBlock(\`<li><block-text-0/></li>\`);
function slot2(ctx, node, key = \\"\\") {
let d2 = ctx['node1'].value;
return block7([d2]);
let txt2 = ctx['node1'].value;
return block7([txt2]);
}
return function template(ctx, node, key = \\"\\") {
@@ -1944,8 +1944,8 @@ exports[`slots slots in t-foreach in t-foreach 1`] = `
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`node1\`] = v_block2[i1];
let key1 = ctx['node1'].key;
let d1 = ctx['node1'].value;
let b4 = block4([d1]);
let txt1 = ctx['node1'].value;
let b4 = block4([txt1]);
ctx = Object.create(ctx);
const [k_block6, v_block6, l_block6, c_block6] = prepareList(ctx['node1'].nodes);
for (let i2 = 0; i2 < l_block6; i2++) {
@@ -2020,9 +2020,9 @@ exports[`slots slots in t-foreach with t-set and re-rendering 2`] = `
let block1 = createBlock(\`<span><block-text-0/><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['state'].val;
let txt1 = ctx['state'].val;
let b2 = callSlot(ctx, node, key, 'default', false, {});
return block1([d1], [b2]);
return block1([txt1], [b2]);
}
}"
`;
@@ -2271,9 +2271,9 @@ exports[`slots t-slot scope context 2`] = `
let block1 = createBlock(\`<div block-handler-0=\\"click\\"><block-child-0/></div>\`);
function slot1(ctx, node, key = \\"\\") {
let d1 = [ctx['onClick'], ctx];
let hdlr1 = [ctx['onClick'], ctx];
let b2 = callSlot(ctx, node, key, 'default', false, {});
return block1([d1], [b2]);
return block1([hdlr1], [b2]);
}
return function template(ctx, node, key = \\"\\") {
@@ -2395,8 +2395,8 @@ exports[`slots template can just return a slot 3`] = `
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['props'].value;
return block1([d1]);
let txt1 = ctx['props'].value;
return block1([txt1]);
}
}"
`;