[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
+4 -6
View File
@@ -761,7 +761,7 @@ export class CodeGenerator {
if (!current) break;
}
}
this.addLine(`let ${block!.children.map((c) => c.varName)};`, codeIdx);
this.addLine(`let ${block!.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
}
return block!.varName;
@@ -863,7 +863,7 @@ export class CodeGenerator {
if (!current) break;
}
}
this.addLine(`let ${block!.children.map((c) => c.varName)};`, codeIdx);
this.addLine(`let ${block!.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
// note: this part is duplicated from end of compilemulti:
@@ -998,8 +998,7 @@ export class CodeGenerator {
}
}
if (isNewBlock) {
if (block!.hasDynamicChildren) {
if (block!.children.length) {
if (block!.hasDynamicChildren && block!.children.length) {
const code = this.target.code;
const children = block!.children.slice();
let current = children.shift();
@@ -1010,8 +1009,7 @@ export class CodeGenerator {
if (!current) break;
}
}
this.addLine(`let ${block!.children.map((c) => c.varName)};`, codeIdx);
}
this.addLine(`let ${block!.children.map((c) => c.varName).join(", ")};`, codeIdx);
}
const args = block!.children.map((c) => c.varName).join(", ");
+1 -1
View File
@@ -22,7 +22,7 @@ exports[`app app: clear scheduler tasks and destroy cancelled nodes immediately
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'].value) {
b3 = comp1({}, key + \`__1\`, node, this, null);
@@ -34,7 +34,7 @@ exports[`comments properly handle comments between t-if/t-else 1`] = `
let block3 = createBlock(\`<span>owl</span>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (true) {
b2 = block2();
} else {
@@ -18,7 +18,7 @@ exports[`misc complex template 1`] = `
let block13 = createBlock(\`<i class=\\"fa fa-fw fa-clock-o\\" title=\\"This commit is the head of a base branch\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b6,b8;
let b2, b3, b4, b6, b8;
let attr1 = \`batch_tile \${ctx['options'].more?'more':'nomore'}\`;
let attr2 = \`card bg-\${ctx['klass']}-light\`;
let attr3 = \`/runbot/batch/\${ctx['batch'].id}\`;
@@ -53,7 +53,7 @@ exports[`misc complex template 1`] = `
for (let i1 = 0; i1 < l_block8; i1++) {
ctx[\`commit_link\`] = k_block8[i1];
const key1 = ctx['commit_link'].id;
let b10,b11,b12,b13;
let b10, b11, b12, b13;
let attr5 = \`/runbot/commit/\${ctx['commit_link'].commit_id}\`;
let attr6 = \`badge badge-light batch_commit match_type_\${ctx['commit_link'].match_type}\`;
if (ctx['commit_link'].match_type=='new') {
@@ -217,7 +217,7 @@ exports[`misc other complex template 1`] = `
let block25 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b4,b14,b17,b22,b23,b24,b25;
let b2, b4, b14, b17, b22, b23, b24, b25;
let attr1 = \`/runbot/\${ctx['project'].slug}\`;
let txt1 = ctx['project'].name;
ctx = Object.create(ctx);
@@ -232,12 +232,12 @@ exports[`misc other complex template 1`] = `
ctx = ctx.__proto__;
b2 = list(c_block2);
if (ctx['user']) {
let b5,b6;
let b5, b6;
if (ctx['user'].public) {
let attr2 = \`/web/login?redirect=/\`;
b5 = block5([attr2]);
} else {
let b7,b10,b13;
let b7, b10, b13;
if (ctx['nb_assigned_errors']&&ctx['nb_assigned_errors']>0) {
let attr3 = \`You have \${ctx['nb_assigned_errors']} random bug assigned\`;
let txt3 = ctx['nb_assigned_errors'];
@@ -928,7 +928,7 @@ exports[`t-call (template calling) t-call, conditional and t-set in t-call body
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
ctx[isBoundary] = 1
let b2,b3;
let b2, b3;
setContextValue(ctx, \\"v1\\", 'elif');
if (ctx['v1']==='if') {
b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
@@ -237,7 +237,7 @@ exports[`t-foreach iterate, position 1`] = `
ctx[\`elem_last\`] = i1 === k_block2.length - 1;
ctx[\`elem_index\`] = i1;
const key1 = ctx['elem'];
let b4,b5,b6,b7,b8,b9;
let b4, b5, b6, b7, b8, b9;
b4 = text(\` -\`);
if (ctx['elem_first']) {
b5 = text(\` first\`);
+16 -16
View File
@@ -8,7 +8,7 @@ exports[`t-if a t-if next to a div 1`] = `
let block2 = createBlock(\`<div>foo</div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = block2();
if (ctx['cond']) {
b3 = text(\`1\`);
@@ -44,7 +44,7 @@ exports[`t-if boolean value condition elif (no outside node) 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5;
let b2, b3, b4, b5;
if (ctx['color']=='black') {
b2 = text(\`black pearl\`);
} else if (ctx['color']=='yellow') {
@@ -67,7 +67,7 @@ exports[`t-if boolean value condition elif 1`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-2/><block-child-3/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5;
let b2, b3, b4, b5;
if (ctx['color']=='black') {
b2 = text(\`black pearl\`);
} else if (ctx['color']=='yellow') {
@@ -90,7 +90,7 @@ exports[`t-if boolean value condition else 1`] = `
let block1 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['condition']) {
b2 = text(\`ok\`);
} else {
@@ -109,7 +109,7 @@ exports[`t-if boolean value condition false else 1`] = `
let block1 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['condition']) {
b2 = text(\`fail\`);
} else {
@@ -145,7 +145,7 @@ exports[`t-if can use some boolean operators in expressions 1`] = `
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-2/><block-child-3/><block-child-4/><block-child-5/><block-child-6/><block-child-7/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3,b4,b5,b6,b7,b8,b9;
let b2, b3, b4, b5, b6, b7, b8, b9;
if (ctx['cond1']&&ctx['cond2']) {
b2 = text(\`and\`);
}
@@ -239,7 +239,7 @@ exports[`t-if simple t-if/t-else 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['condition']) {
b2 = text(\`1\`);
} else {
@@ -258,7 +258,7 @@ exports[`t-if simple t-if/t-else in a div 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['condition']) {
b2 = text(\`1\`);
} else {
@@ -277,7 +277,7 @@ exports[`t-if t-esc with t-elif 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 (false) {
b2 = text(\`abc\`);
} else {
@@ -314,7 +314,7 @@ exports[`t-if t-if and t-else with two nodes 1`] = `
let block5 = createBlock(\`<span>b</span>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['condition']) {
b2 = text(\`1\`);
} else {
@@ -372,7 +372,7 @@ exports[`t-if t-if with empty content 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
b2 = text(\`hello\`);
if (ctx['condition']) {
b3 = text(\`\`);
@@ -388,7 +388,7 @@ exports[`t-if t-if/t-else with more content 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['condition']) {
if (ctx['condition']) {
b2 = text(\`asf\`);
@@ -458,7 +458,7 @@ exports[`t-if t-set, then t-if, part 3 1`] = `
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
ctx[isBoundary] = 1
let b2,b3;
let b2, b3;
setContextValue(ctx, \\"y\\", false);
setContextValue(ctx, \\"x\\", ctx['y']);
if (ctx['x']) {
@@ -477,7 +477,7 @@ exports[`t-if two consecutive t-if 1`] = `
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['cond1']) {
b2 = text(\`1\`);
}
@@ -497,7 +497,7 @@ exports[`t-if two consecutive t-if in a div 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['cond1']) {
b2 = text(\`1\`);
}
@@ -520,7 +520,7 @@ exports[`t-if two t-ifs next to each other 1`] = `
let block5 = createBlock(\`<p>2</p>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['condition']) {
let txt1 = ctx['text'];
b2 = block2([txt1]);
@@ -79,7 +79,7 @@ exports[`t-key t-key on sub dom node pushes a child block in its parent 1`] = `
let block3 = createBlock(\`<div><h1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['hasSpan']) {
b2 = block2();
}
@@ -309,7 +309,7 @@ exports[`t-out t-out switch markup on bdom 1`] = `
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
ctx[isBoundary] = 1
let b3,b5;
let b3, b5;
ctx[\`bdom\`] = new LazyValue(value1, ctx, this, node, key);
if (ctx['hasBdom']) {
const b4 = safeOutput(ctx['bdom']);
@@ -94,7 +94,7 @@ exports[`t-set set from body literal (with t-if/t-else 1`] = `
let { isBoundary, withDefault, LazyValue } = helpers;
function value1(ctx, node, key = \\"\\") {
let b2,b3;
let b2, b3;
if (ctx['condition']) {
b2 = text(\`true\`);
} else {
@@ -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';
+4 -4
View File
@@ -345,7 +345,7 @@ exports[`Portal conditional use of Portal (with sub Component) 1`] = `
}
return function template(ctx, node, key = \\"\\") {
let b2,b4;
let b2, b4;
b2 = block2();
if (ctx['state'].hasPortal) {
b4 = comp2({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__2\`, node, ctx, Portal);
@@ -384,7 +384,7 @@ exports[`Portal conditional use of Portal 1`] = `
}
return function template(ctx, node, key = \\"\\") {
let b2,b4;
let b2, b4;
b2 = block2();
if (ctx['state'].hasPortal) {
b4 = comp1({target: '#outside',slots: {'default': {__render: slot1.bind(this), __ctx: ctx}}}, key + \`__1\`, node, ctx, Portal);
@@ -699,7 +699,7 @@ exports[`Portal portal with dynamic body 1`] = `
let block4 = createBlock(\`<div/>\`);
function slot1(ctx, node, key = \\"\\") {
let b3,b4;
let b3, b4;
if (ctx['state'].val) {
let txt1 = ctx['state'].val;
b3 = block3([txt1]);
@@ -848,7 +848,7 @@ exports[`Portal simple catchError with portal 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 {