[IMP] compiler: improve generated compiled code

This commit is contained in:
Géry Debongnie
2021-12-22 11:33:12 +01:00
committed by Aaron Bohy
parent bd5637c0a3
commit c7af885f43
36 changed files with 939 additions and 936 deletions
@@ -8,10 +8,10 @@ exports[`event handling handler receive the event as argument 1`] = `
let block1 = createBlock(\`<span block-handler-0=\\"click\\"><block-child-0/><block-text-1/></span>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = [ctx['inc'], ctx];
let hdlr1 = [ctx['inc'], ctx];
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
let d2 = ctx['state'].value;
return block1([d1, d2], [b2]);
let txt2 = ctx['state'].value;
return block1([hdlr1, txt2], [b2]);
}
}"
`;
@@ -46,8 +46,8 @@ exports[`event handling objects from scope are properly captured by t-on 1`] = `
let key1 = ctx['item'];
const v1 = ctx['onClick'];
const v2 = ctx['item'];
let d1 = [ev=>v1(v2.val,ev), ctx];
c_block2[i1] = withKey(block3([d1]), key1);
let hdlr1 = [ev=>v1(v2.val,ev), ctx];
c_block2[i1] = withKey(block3([hdlr1]), key1);
}
let b2 = list(c_block2);
return block1([], [b2]);
@@ -63,9 +63,9 @@ exports[`event handling support for callable expression in event handler 1`] = `
let block1 = createBlock(\`<div><block-text-0/><input type=\\"text\\" block-handler-1=\\"input\\"/></div>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['state'].value;
let d2 = [ctx['obj'].onInput, ctx];
return block1([d1, d2]);
let txt1 = ctx['state'].value;
let hdlr2 = [ctx['obj'].onInput, ctx];
return block1([txt1, hdlr2]);
}
}"
`;
@@ -87,8 +87,8 @@ exports[`event handling t-on with handler bound to dynamic argument on a t-forea
let key1 = ctx['item'];
const v1 = ctx['onClick'];
const v2 = ctx['item'];
let d1 = [ev=>v1(v2,ev), ctx];
c_block2[i1] = withKey(block3([d1]), key1);
let hdlr1 = [ev=>v1(v2,ev), ctx];
c_block2[i1] = withKey(block3([hdlr1]), key1);
}
let b2 = list(c_block2);
return block1([], [b2]);