From 28672096a29cc30da3c362df2621b7fa5e5c5777 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Fri, 4 Aug 2023 08:49:08 +0200 Subject: [PATCH] [REF] compiler: minor cleanup This commit merges two nested ifs and explicitly joins an array instead of relying on array -> string coercion --- src/compiler/code_generator.ts | 26 +++++++------- tests/app/__snapshots__/app.test.ts.snap | 2 +- .../__snapshots__/comments.test.ts.snap | 2 +- .../compiler/__snapshots__/misc.test.ts.snap | 10 +++--- .../__snapshots__/t_call.test.ts.snap | 2 +- .../__snapshots__/t_foreach.test.ts.snap | 2 +- .../compiler/__snapshots__/t_if.test.ts.snap | 32 ++++++++--------- .../compiler/__snapshots__/t_key.test.ts.snap | 2 +- .../compiler/__snapshots__/t_out.test.ts.snap | 2 +- .../compiler/__snapshots__/t_set.test.ts.snap | 2 +- .../__snapshots__/basics.test.ts.snap | 12 +++---- .../__snapshots__/concurrency.test.ts.snap | 26 +++++++------- .../__snapshots__/error_handling.test.ts.snap | 36 +++++++++---------- .../higher_order_component.test.ts.snap | 4 +-- .../__snapshots__/lifecycle.test.ts.snap | 6 ++-- .../props_validation.test.ts.snap | 2 +- .../__snapshots__/refs.test.ts.snap | 2 +- .../__snapshots__/slots.test.ts.snap | 14 ++++---- .../__snapshots__/style_class.test.ts.snap | 2 +- .../__snapshots__/t_call.test.ts.snap | 2 +- .../__snapshots__/t_model.test.ts.snap | 4 +-- tests/misc/__snapshots__/portal.test.ts.snap | 8 ++--- 22 files changed, 99 insertions(+), 101 deletions(-) diff --git a/src/compiler/code_generator.ts b/src/compiler/code_generator.ts index 8b20c62b..ec76367e 100644 --- a/src/compiler/code_generator.ts +++ b/src/compiler/code_generator.ts @@ -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,20 +998,18 @@ export class CodeGenerator { } } if (isNewBlock) { - if (block!.hasDynamicChildren) { - if (block!.children.length) { - const code = this.target.code; - const children = block!.children.slice(); - let current = children.shift(); - for (let i = codeIdx; i < code.length; i++) { - if (code[i].trimStart().startsWith(`const ${current!.varName} `)) { - code[i] = code[i].replace(`const ${current!.varName}`, current!.varName); - current = children.shift(); - if (!current) break; - } + if (block!.hasDynamicChildren && block!.children.length) { + const code = this.target.code; + const children = block!.children.slice(); + let current = children.shift(); + for (let i = codeIdx; i < code.length; i++) { + if (code[i].trimStart().startsWith(`const ${current!.varName} `)) { + code[i] = code[i].replace(`const ${current!.varName}`, current!.varName); + current = children.shift(); + 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(", "); diff --git a/tests/app/__snapshots__/app.test.ts.snap b/tests/app/__snapshots__/app.test.ts.snap index 309c2dda..64962488 100644 --- a/tests/app/__snapshots__/app.test.ts.snap +++ b/tests/app/__snapshots__/app.test.ts.snap @@ -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); diff --git a/tests/compiler/__snapshots__/comments.test.ts.snap b/tests/compiler/__snapshots__/comments.test.ts.snap index 1bc52a4f..3547aed8 100644 --- a/tests/compiler/__snapshots__/comments.test.ts.snap +++ b/tests/compiler/__snapshots__/comments.test.ts.snap @@ -34,7 +34,7 @@ exports[`comments properly handle comments between t-if/t-else 1`] = ` let block3 = createBlock(\`owl\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2, b3; if (true) { b2 = block2(); } else { diff --git a/tests/compiler/__snapshots__/misc.test.ts.snap b/tests/compiler/__snapshots__/misc.test.ts.snap index b4440b9d..acca63db 100644 --- a/tests/compiler/__snapshots__/misc.test.ts.snap +++ b/tests/compiler/__snapshots__/misc.test.ts.snap @@ -18,7 +18,7 @@ exports[`misc complex template 1`] = ` let block13 = createBlock(\`\`); 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(\`
\`); 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']; diff --git a/tests/compiler/__snapshots__/t_call.test.ts.snap b/tests/compiler/__snapshots__/t_call.test.ts.snap index 2833f8f8..dd3fd2b3 100644 --- a/tests/compiler/__snapshots__/t_call.test.ts.snap +++ b/tests/compiler/__snapshots__/t_call.test.ts.snap @@ -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\`); diff --git a/tests/compiler/__snapshots__/t_foreach.test.ts.snap b/tests/compiler/__snapshots__/t_foreach.test.ts.snap index c144096e..0483f41e 100644 --- a/tests/compiler/__snapshots__/t_foreach.test.ts.snap +++ b/tests/compiler/__snapshots__/t_foreach.test.ts.snap @@ -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\`); diff --git a/tests/compiler/__snapshots__/t_if.test.ts.snap b/tests/compiler/__snapshots__/t_if.test.ts.snap index 4f3f6be2..2c515a55 100644 --- a/tests/compiler/__snapshots__/t_if.test.ts.snap +++ b/tests/compiler/__snapshots__/t_if.test.ts.snap @@ -8,7 +8,7 @@ exports[`t-if a t-if next to a div 1`] = ` let block2 = createBlock(\`
foo
\`); 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(\`
\`); 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(\`
beginend
\`); 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(\`
beginend
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`b\`); 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(\`
\`); 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(\`

2

\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2, b3; if (ctx['condition']) { let txt1 = ctx['text']; b2 = block2([txt1]); diff --git a/tests/compiler/__snapshots__/t_key.test.ts.snap b/tests/compiler/__snapshots__/t_key.test.ts.snap index 1c664842..e51d1dc0 100644 --- a/tests/compiler/__snapshots__/t_key.test.ts.snap +++ b/tests/compiler/__snapshots__/t_key.test.ts.snap @@ -79,7 +79,7 @@ exports[`t-key t-key on sub dom node pushes a child block in its parent 1`] = ` let block3 = createBlock(\`

\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2, b3; if (ctx['hasSpan']) { b2 = block2(); } diff --git a/tests/compiler/__snapshots__/t_out.test.ts.snap b/tests/compiler/__snapshots__/t_out.test.ts.snap index 0d01b718..49ec6d67 100644 --- a/tests/compiler/__snapshots__/t_out.test.ts.snap +++ b/tests/compiler/__snapshots__/t_out.test.ts.snap @@ -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']); diff --git a/tests/compiler/__snapshots__/t_set.test.ts.snap b/tests/compiler/__snapshots__/t_set.test.ts.snap index ffbdd43f..b4320fe5 100644 --- a/tests/compiler/__snapshots__/t_set.test.ts.snap +++ b/tests/compiler/__snapshots__/t_set.test.ts.snap @@ -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 { diff --git a/tests/components/__snapshots__/basics.test.ts.snap b/tests/components/__snapshots__/basics.test.ts.snap index ff241b1b..f72b260c 100644 --- a/tests/components/__snapshots__/basics.test.ts.snap +++ b/tests/components/__snapshots__/basics.test.ts.snap @@ -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(\`test\`); 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(\`
somediv
\`); 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(\`
somediv
\`); 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(\`
somediv
\`); 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(\`
\`); 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)); diff --git a/tests/components/__snapshots__/concurrency.test.ts.snap b/tests/components/__snapshots__/concurrency.test.ts.snap index 74c8141c..6b263e7e 100644 --- a/tests/components/__snapshots__/concurrency.test.ts.snap +++ b/tests/components/__snapshots__/concurrency.test.ts.snap @@ -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(\`
\`); 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(\`
\`); 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(\`
\`); 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); diff --git a/tests/components/__snapshots__/error_handling.test.ts.snap b/tests/components/__snapshots__/error_handling.test.ts.snap index aec2b19d..7ddb11a6 100644 --- a/tests/components/__snapshots__/error_handling.test.ts.snap +++ b/tests/components/__snapshots__/error_handling.test.ts.snap @@ -103,7 +103,7 @@ exports[`basics simple catchError 1`] = ` let block1 = createBlock(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); 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(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2, b3; if (!ctx['state'].error) { b2 = text(ctx['this'].will.crash); } else { diff --git a/tests/components/__snapshots__/higher_order_component.test.ts.snap b/tests/components/__snapshots__/higher_order_component.test.ts.snap index 8b5de999..1b296974 100644 --- a/tests/components/__snapshots__/higher_order_component.test.ts.snap +++ b/tests/components/__snapshots__/higher_order_component.test.ts.snap @@ -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); } diff --git a/tests/components/__snapshots__/lifecycle.test.ts.snap b/tests/components/__snapshots__/lifecycle.test.ts.snap index e24b0974..24b54f60 100644 --- a/tests/components/__snapshots__/lifecycle.test.ts.snap +++ b/tests/components/__snapshots__/lifecycle.test.ts.snap @@ -54,7 +54,7 @@ exports[`lifecycle hooks component semantics 3`] = ` let block1 = createBlock(\`
C
\`); 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(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2, b3; if (ctx['state'].ok) { b2 = comp1({}, key + \`__1\`, node, this, null); } else { diff --git a/tests/components/__snapshots__/props_validation.test.ts.snap b/tests/components/__snapshots__/props_validation.test.ts.snap index 081ab66e..910f0e5b 100644 --- a/tests/components/__snapshots__/props_validation.test.ts.snap +++ b/tests/components/__snapshots__/props_validation.test.ts.snap @@ -39,7 +39,7 @@ exports[`default props can set default boolean values 2`] = ` let block1 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2, b3; if (ctx['props'].p) { b2 = text(\`hey\`); } diff --git a/tests/components/__snapshots__/refs.test.ts.snap b/tests/components/__snapshots__/refs.test.ts.snap index e15027c7..2e85192b 100644 --- a/tests/components/__snapshots__/refs.test.ts.snap +++ b/tests/components/__snapshots__/refs.test.ts.snap @@ -23,7 +23,7 @@ exports[`refs can use 2 refs with same name in a t-if/t-else situation 1`] = ` let block3 = createBlock(\`\`); 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]); diff --git a/tests/components/__snapshots__/slots.test.ts.snap b/tests/components/__snapshots__/slots.test.ts.snap index dc8584e0..2034ed5d 100644 --- a/tests/components/__snapshots__/slots.test.ts.snap +++ b/tests/components/__snapshots__/slots.test.ts.snap @@ -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(\`

\`); 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(\`

\`); 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 { diff --git a/tests/components/__snapshots__/style_class.test.ts.snap b/tests/components/__snapshots__/style_class.test.ts.snap index 55f0d25a..72395cb6 100644 --- a/tests/components/__snapshots__/style_class.test.ts.snap +++ b/tests/components/__snapshots__/style_class.test.ts.snap @@ -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 { diff --git a/tests/components/__snapshots__/t_call.test.ts.snap b/tests/components/__snapshots__/t_call.test.ts.snap index 4e95b6c0..ee43b15c 100644 --- a/tests/components/__snapshots__/t_call.test.ts.snap +++ b/tests/components/__snapshots__/t_call.test.ts.snap @@ -364,7 +364,7 @@ exports[`t-call sub components in two t-calls 1`] = ` let block3 = createBlock(\`
\`); 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 { diff --git a/tests/components/__snapshots__/t_model.test.ts.snap b/tests/components/__snapshots__/t_model.test.ts.snap index 7c08e043..1d1e0e90 100644 --- a/tests/components/__snapshots__/t_model.test.ts.snap +++ b/tests/components/__snapshots__/t_model.test.ts.snap @@ -376,7 +376,7 @@ exports[`t-model directive on an input, type=checkbox 1`] = ` let block1 = createBlock(\`
\`); 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(\`\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2, b3; if (ctx['state'].flag) { const bExpr1 = ctx['state']; const expr1 = 'text1'; diff --git a/tests/misc/__snapshots__/portal.test.ts.snap b/tests/misc/__snapshots__/portal.test.ts.snap index 951e4eeb..868171dc 100644 --- a/tests/misc/__snapshots__/portal.test.ts.snap +++ b/tests/misc/__snapshots__/portal.test.ts.snap @@ -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(\`
\`); 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(\`
\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2, b3; if (ctx['error']) { b2 = text(\`Error\`); } else {