[REF] compiler: minor cleanup

This commit merges two nested ifs and explicitly joins an array instead
of relying on array -> string coercion
This commit is contained in:
Samuel Degueldre
2023-08-04 08:49:08 +02:00
committed by Lucas Perais - lpe@odoo
parent 9823a4e7dd
commit 28672096a2
22 changed files with 99 additions and 101 deletions
@@ -440,7 +440,7 @@ exports[`basics higher order components parent and child 2`] = `
const comp2 = app.createComponent(\`ChildB\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['props'].child==='a') {
b2 = comp1({}, key + \`__1\`, node, this, null);
} else {
@@ -738,7 +738,7 @@ exports[`basics sub components between t-ifs 1`] = `
let block5 = createBlock(\`<span>test</span>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5;
let b2, b3, b4, b5;
if (ctx['state'].flag) {
b2 = block2();
} else {
@@ -776,7 +776,7 @@ exports[`basics t-elif works with t-component 1`] = `
let block2 = createBlock(\`<div>somediv</div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].flag) {
b2 = block2();
} else if (!ctx['state'].flag) {
@@ -810,7 +810,7 @@ exports[`basics t-else with empty string works with t-component 1`] = `
let block2 = createBlock(\`<div>somediv</div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].flag) {
b2 = block2();
} else {
@@ -844,7 +844,7 @@ exports[`basics t-else works with t-component 1`] = `
let block2 = createBlock(\`<div>somediv</div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].flag) {
b2 = block2();
} else {
@@ -909,7 +909,7 @@ exports[`basics t-key on a component with t-if, and a sibling component 1`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (false) {
const tKey_1 = 'str';
b2 = toggler(tKey_1, comp1({}, tKey_1 + key + \`__1\`, node, this, null));
@@ -61,7 +61,7 @@ exports[`another scenario with delayed rendering 1`] = `
const comp1 = app.createComponent(\`B\`, true, false, false, [\\"value\\"]);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(\`A\`);
if (ctx['state'].value<15) {
b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
@@ -244,7 +244,7 @@ exports[`components are not destroyed between animation frame 1`] = `
const comp1 = app.createComponent(\`B\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(\`A\`);
if (ctx['state'].flag) {
b3 = comp1({}, key + \`__1\`, node, this, null);
@@ -831,7 +831,7 @@ exports[`concurrent renderings scenario 13 1`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = comp1({}, key + \`__1\`, node, this, null);
if (ctx['state'].bool) {
b3 = comp2({}, key + \`__2\`, node, this, null);
@@ -978,7 +978,7 @@ exports[`concurrent renderings scenario 16 3`] = `
const comp1 = app.createComponent(\`D\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5,b6,b7,b8;
let b2, b3, b4, b5, b6, b7, b8;
b2 = text(ctx['props'].fromA);
b3 = text(\`:\`);
b4 = text(ctx['props'].fromB);
@@ -1012,7 +1012,7 @@ exports[`creating two async components, scenario 1 1`] = `
const comp2 = app.createComponent(\`ChildB\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].flagA) {
b2 = comp1({}, key + \`__1\`, node, this, null);
}
@@ -1061,7 +1061,7 @@ exports[`creating two async components, scenario 2 1`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null);
if (ctx['state'].flagB) {
b3 = comp2({val: ctx['state'].valB}, key + \`__2\`, node, this, null);
@@ -1109,7 +1109,7 @@ exports[`creating two async components, scenario 3 (patching in the same frame)
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null);
if (ctx['state'].flagB) {
b3 = comp2({val: ctx['state'].valB}, key + \`__2\`, node, this, null);
@@ -1421,7 +1421,7 @@ exports[`delayed rendering, destruction, stuff happens 2`] = `
const comp1 = app.createComponent(\`C\`, true, false, false, [\\"value\\"]);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(\`B\`);
if (ctx['state'].hasChild) {
b3 = comp1({value: ctx['state'].someValue+ctx['props'].value}, key + \`__1\`, node, this, null);
@@ -1514,7 +1514,7 @@ exports[`delayed rendering, reusing fiber then component is destroyed and stuff
const comp1 = app.createComponent(\`B\`, true, false, false, [\\"value\\"]);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(\`A\`);
if (ctx['state'].value<15) {
b3 = comp1({value: ctx['state'].value}, key + \`__1\`, node, this, null);
@@ -1572,7 +1572,7 @@ exports[`delayed rendering, then component is destroyed and stuff 2`] = `
const comp1 = app.createComponent(\`C\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(ctx['props'].value);
if (ctx['props'].value<10) {
b3 = comp1({}, key + \`__1\`, node, this, null);
@@ -1605,7 +1605,7 @@ exports[`destroyed component causes other soon to be destroyed component to rere
const comp2 = app.createComponent(\`C\`, true, false, false, [\\"value\\"]);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(\` A \`);
if (ctx['state'].flag) {
const b4 = comp1({value: ctx['state'].valueB}, key + \`__1\`, node, this, null);
@@ -1646,7 +1646,7 @@ exports[`destroying/recreating a subcomponent, other scenario 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(\`parent\`);
if (ctx['state'].hasChild) {
b3 = comp1({}, key + \`__1\`, node, this, null);
@@ -1846,7 +1846,7 @@ exports[`renderings, destruction, patch, stuff, ... yet another variation 2`] =
const comp1 = app.createComponent(\`C\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(\`B\`);
if (ctx['props'].value===33) {
b3 = comp1({}, key + \`__1\`, node, this, null);
@@ -103,7 +103,7 @@ exports[`basics simple catchError 1`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['error']) {
b2 = text(\`Error\`);
} else {
@@ -201,7 +201,7 @@ exports[`can catch errors an error in onWillDestroy 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(ctx['state'].value);
if (ctx['state'].hasChild) {
b3 = comp1({}, key + \`__1\`, node, this, null);
@@ -231,7 +231,7 @@ exports[`can catch errors an error in onWillDestroy, variation 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(ctx['state'].value);
if (ctx['state'].hasChild) {
b3 = comp1({}, key + \`__1\`, node, this, null);
@@ -295,7 +295,7 @@ exports[`can catch errors can catch an error in a component render function 2`]
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -350,7 +350,7 @@ exports[`can catch errors can catch an error in the constructor call of a compon
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -394,7 +394,7 @@ exports[`can catch errors can catch an error in the constructor call of a compon
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -474,7 +474,7 @@ exports[`can catch errors can catch an error in the initial call of a component
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -532,7 +532,7 @@ exports[`can catch errors can catch an error in the initial call of a component
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -593,7 +593,7 @@ exports[`can catch errors can catch an error in the mounted call (in child of ch
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -626,7 +626,7 @@ exports[`can catch errors can catch an error in the mounted call (in root compon
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -680,7 +680,7 @@ exports[`can catch errors can catch an error in the mounted call 2`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -735,7 +735,7 @@ exports[`can catch errors can catch an error in the willPatch call 2`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -790,7 +790,7 @@ exports[`can catch errors can catch an error in the willStart call 2`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -847,7 +847,7 @@ exports[`can catch errors can catch an error origination from a child's willStar
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -893,7 +893,7 @@ exports[`can catch errors catchError in catchError 1`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['error']) {
b2 = text(\`Error\`);
} else {
@@ -1123,7 +1123,7 @@ exports[`can catch errors error in mounted on a component with a sibling (proper
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].error) {
b2 = text(\`Error handled\`);
} else {
@@ -1167,7 +1167,7 @@ exports[`can catch errors onError in class inheritance is called if rethrown 2`]
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (!ctx['state'].error) {
b2 = text(ctx['this'].will.crash);
} else {
@@ -1198,7 +1198,7 @@ exports[`can catch errors onError in class inheritance is not called if no rethr
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (!ctx['state'].error) {
b2 = text(ctx['this'].will.crash);
} else {
@@ -34,7 +34,7 @@ exports[`basics can select a sub widget 1`] = `
const comp2 = app.createComponent(\`OtherChild\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['env'].options.flag) {
b2 = comp1({}, key + \`__1\`, node, this, null);
}
@@ -80,7 +80,7 @@ exports[`basics can select a sub widget, part 2 1`] = `
const comp2 = app.createComponent(\`OtherChild\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, this, null);
}
@@ -54,7 +54,7 @@ exports[`lifecycle hooks component semantics 3`] = `
let block1 = createBlock(\`<div>C<block-child-0/><block-child-1/><block-child-2/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3,b4;
let b2, b3, b4;
b2 = comp1({}, key + \`__1\`, node, this, null);
if (ctx['state'].flag) {
b3 = comp2({}, key + \`__2\`, node, this, null);
@@ -174,7 +174,7 @@ exports[`lifecycle hooks destroy new children before being mountged 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
return function template(ctx, node, key = \\"\\") {
let b2,b3,b4;
let b2, b3, b4;
b2 = text(\`before\`);
if (ctx['state'].flag) {
b3 = comp1({}, key + \`__1\`, node, this, null);
@@ -826,7 +826,7 @@ exports[`lifecycle hooks willStart, mounted on subwidget rendered after main is
let block3 = createBlock(\`<div/>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].ok) {
b2 = comp1({}, key + \`__1\`, node, this, null);
} else {
@@ -39,7 +39,7 @@ exports[`default props can set default boolean values 2`] = `
let block1 = createBlock(\`<span><block-child-0/><block-child-1/></span>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['props'].p) {
b2 = text(\`hey\`);
}
@@ -23,7 +23,7 @@ exports[`refs can use 2 refs with same name in a t-if/t-else situation 1`] = `
let block3 = createBlock(\`<span block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].value) {
let ref1 = (el) => this.__owl__.setRef((\`coucou\`), el);
b2 = block2([ref1]);
@@ -509,7 +509,7 @@ exports[`slots default slot with slot scope: shorthand syntax 1`] = `
const comp1 = app.createComponent(\`Child\`, true, true, false, []);
function slot1(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['slotScope'].bool) {
b2 = text(\`some text\`);
} else {
@@ -633,7 +633,7 @@ exports[`slots dynamic slot in multiple locations 2`] = `
let block2 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b4;
let b2, b4;
if (ctx['props'].location===1) {
const slot1 = ('coffee');
const b3 = toggler(slot1, callSlot(ctx, node, key + \`__1\`, slot1, true, {}));
@@ -1462,7 +1462,7 @@ exports[`slots simple default slot with params 1`] = `
const comp1 = app.createComponent(\`Child\`, true, true, false, []);
function slot1(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['slotScope'].bool) {
b2 = text(\`some text\`);
} else {
@@ -1558,7 +1558,7 @@ exports[`slots simple dynamic slot with slot scope 1`] = `
const comp1 = app.createComponent(\`Child\`, true, true, false, []);
function slot1(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['slotScope'].bool) {
b2 = text(\`some text\`);
} else {
@@ -1665,7 +1665,7 @@ exports[`slots simple slot with slot scope 1`] = `
const comp1 = app.createComponent(\`Child\`, true, true, false, []);
function slot1(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['slotScope'].bool) {
b2 = text(\`some text\`);
} else {
@@ -2082,7 +2082,7 @@ exports[`slots slot in multiple locations 2`] = `
let block2 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b4;
let b2, b4;
if (ctx['props'].location===1) {
const b3 = callSlot(ctx, node, key, 'default', false, {});
b2 = block2([], [b3]);
@@ -2887,7 +2887,7 @@ exports[`slots t-slot in recursive templates 1`] = `
ctx[\`item_index\`] = i1;
ctx[\`item_value\`] = v_block3[i1];
const key1 = ctx['item'].name;
let b5,b6;
let b5, b6;
if (!ctx['item'].children.length) {
b5 = text(ctx['item'].name);
} else {
@@ -166,7 +166,7 @@ exports[`style and class handling class on sub component, which is switched to a
const comp2 = app.createComponent(\`ChildB\`, true, false, false, [\\"class\\"]);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['props'].child==='a') {
b2 = comp1({class: ctx['props'].class}, key + \`__1\`, node, this, null);
} else {
@@ -364,7 +364,7 @@ exports[`t-call sub components in two t-calls 1`] = `
let block3 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].val===1) {
b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
} else {
@@ -376,7 +376,7 @@ exports[`t-model directive on an input, type=checkbox 1`] = `
let block1 = createBlock(\`<div><input type=\\"checkbox\\" block-property-0=\\"checked\\" block-handler-1=\\"input\\"/><span><block-child-0/><block-child-1/></span></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
const bExpr1 = ctx['state'];
const expr1 = 'flag';
let prop1 = bExpr1[expr1];
@@ -640,7 +640,7 @@ exports[`t-model directive two inputs in a div alternating with a t-if 1`] = `
let block3 = createBlock(\`<input class=\\"b\\" block-property-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['state'].flag) {
const bExpr1 = ctx['state'];
const expr1 = 'text1';