[IMP] qweb: re-add support of t-on directive

We add some test for the t-on directive.

For making them pass, it was necessary to change the code produced by
compileTForeach: the const declaration is not done by using generateId
and there was some conflict with the variable names produced in
captureExpression. Consequently, many snapshots had to be changed.

Code prettification has been done too.
This commit is contained in:
Mathieu Duckerts-Antoine
2021-10-15 13:08:07 +02:00
committed by Géry Debongnie
parent 55ef9ca116
commit 5f1e1e189f
16 changed files with 628 additions and 326 deletions
@@ -74,16 +74,16 @@ exports[`t-on can bind handlers with empty object (with non empty inner string)
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
const [k2, v2, l2, c2] = prepareList(['someval']);
for (let i1 = 0; i1 < l2; i1++) {
ctx[\`action\`] = v2[i1];
const [k_block2, v_block2, l_block2, c_block2] = prepareList(['someval']);
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`action\`] = v_block2[i1];
ctx[\`action_index\`] = i1;
let key1 = ctx['action_index'];
const arg1 = [ctx['action']];
let d1 = [ctx, 'activate', arg1];
c2[i1] = withKey(block3([d1]), key1);
c_block2[i1] = withKey(block3([d1]), key1);
}
let b2 = list(c2);
let b2 = list(c_block2);
return block1([], [b2]);
}
}"
@@ -146,14 +146,14 @@ exports[`t-on handler is bound to proper owner, part 2 1`] = `
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
const [k1, v1, l1, c1] = prepareList([1]);
for (let i1 = 0; i1 < l1; i1++) {
ctx[\`value\`] = v1[i1];
const [k_block1, v_block1, l_block1, c_block1] = prepareList([1]);
for (let i1 = 0; i1 < l_block1; i1++) {
ctx[\`value\`] = v_block1[i1];
let key1 = ctx['value'];
let d1 = [ctx, 'add'];
c1[i1] = withKey(block2([d1]), key1);
c_block1[i1] = withKey(block2([d1]), key1);
}
return list(c1);
return list(c_block1);
}
}"
`;
@@ -210,17 +210,17 @@ exports[`t-on handler is bound to proper owner, part 4 2`] = `
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
const [k1, v1, l1, c1] = prepareList([1]);
for (let i1 = 0; i1 < l1; i1++) {
ctx[\`value\`] = v1[i1];
const [k_block1, v_block1, l_block1, c_block1] = prepareList([1]);
for (let i1 = 0; i1 < l_block1; i1++) {
ctx[\`value\`] = v_block1[i1];
ctx[\`value_first\`] = i1 === 0;
ctx[\`value_last\`] = i1 === v1.length - 1;
ctx[\`value_last\`] = i1 === v_block1.length - 1;
ctx[\`value_index\`] = i1;
ctx[\`value_value\`] = k1[i1];
ctx[\`value_value\`] = k_block1[i1];
let key1 = ctx['value'];
c1[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
c_block1[i1] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}\`), key1);
}
return list(c1);
return list(c_block1);
}
}"
`;