diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 540e4a70..e0c8bb86 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -258,16 +258,12 @@ function parseTNode(node: Element, ctx: ParsingContext): AST | null { // ----------------------------------------------------------------------------- // Text and Comment Nodes // ----------------------------------------------------------------------------- -const lineBreakRE = /[\r\n]/; -const whitespaceRE = /\s+/g; +const whitespaceRE = /[^\S\r\n]+/g; function parseTextCommentNode(node: Node, ctx: ParsingContext): AST | null { if (node.nodeType === Node.TEXT_NODE) { let value = node.textContent || ""; if (!ctx.inPreTag) { - if (lineBreakRE.test(value) && !value.trim()) { - return null; - } value = value.replace(whitespaceRE, " "); } diff --git a/tests/__snapshots__/reactivity.test.ts.snap b/tests/__snapshots__/reactivity.test.ts.snap index 01a773a1..d207ddd3 100644 --- a/tests/__snapshots__/reactivity.test.ts.snap +++ b/tests/__snapshots__/reactivity.test.ts.snap @@ -347,21 +347,33 @@ exports[`Reactivity: useState useless atoms should be deleted 1`] = ` let { prepareList, withKey } = helpers; const comp1 = app.createComponent(\`Quantity\`, true, false, false, false); - let block1 = createBlock(\`
Total: Count:
\`); + let block3 = createBlock(\`
+ + Total: + Count: +
\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(Object.keys(ctx['state']));; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`id\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(Object.keys(ctx['state']));; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`id\`] = v_block4[i1]; const key1 = ctx['id']; - c_block2[i1] = withKey(comp1({id: ctx['id']}, key + \`__1__\${key1}\`, node, this, null), key1); + const b6 = text(\` + \`); + const b7 = comp1({id: ctx['id']}, key + \`__1__\${key1}\`, node, this, null); + const b8 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b8]), key1); } ctx = ctx.__proto__; - const b2 = list(c_block2); + const b4 = list(c_block4); let txt1 = ctx['total']; let txt2 = Object.keys(ctx['state']).length; - return block1([txt1, txt2], [b2]); + const b3 = block3([txt1, txt2], [b4]); + return multi([b2, b3]); } }" `; diff --git a/tests/compiler/__snapshots__/attributes.test.ts.snap b/tests/compiler/__snapshots__/attributes.test.ts.snap index f4e51d84..b6907160 100644 --- a/tests/compiler/__snapshots__/attributes.test.ts.snap +++ b/tests/compiler/__snapshots__/attributes.test.ts.snap @@ -342,14 +342,20 @@ exports[`attributes from object variables set previously 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
\`); + let block3 = createBlock(\`
+ + +
\`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"o\\", {a:'b'}); let attr1 = ctx['o'].a; - return block1([attr1]); + const b3 = block3([attr1]); + return multi([b2, b3]); } }" `; @@ -360,14 +366,19 @@ exports[`attributes from variables set previously (no external node) 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`\`); + let block4 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"abc\\", 'def'); + const b3 = text(\` + \`); let attr1 = ctx['abc']; - return block1([attr1]); + const b4 = block4([attr1]); + return multi([b2, b3, b4]); } }" `; @@ -713,13 +724,16 @@ exports[`attributes various escapes 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
\`); + let block3 = createBlock(\`
\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let attr1 = ctx['bar']; let attr2 = \`<\${ctx['baz']}>\`; let attr3 = ctx['qux']; - return block1([attr1, attr2, attr3]); + const b3 = block3([attr1, attr2, attr3]); + return multi([b2, b3]); } }" `; @@ -784,11 +798,18 @@ exports[`special cases for some specific html attributes/properties select with ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`\`); + let block3 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let attr1 = ctx['value']; - return block1([attr1]); + const b3 = block3([attr1]); + return multi([b2, b3]); } }" `; @@ -812,10 +833,23 @@ exports[`special cases for some specific html attributes/properties various bool ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
\`); + let block3 = createBlock(\`
+ + +
+
+
\`); return function template(ctx, node, key = \\"\\") { - return block1(); + const b2 = text(\` + \`); + const b3 = block3(); + const b4 = text(\` + \`); + return multi([b2, b3, b4]); } }" `; diff --git a/tests/compiler/__snapshots__/comments.test.ts.snap b/tests/compiler/__snapshots__/comments.test.ts.snap index 1bc52a4f..625aeed0 100644 --- a/tests/compiler/__snapshots__/comments.test.ts.snap +++ b/tests/compiler/__snapshots__/comments.test.ts.snap @@ -29,18 +29,23 @@ exports[`comments properly handle comments between t-if/t-else 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
\`); - let block2 = createBlock(\`true\`); - let block3 = createBlock(\`owl\`); + let block3 = createBlock(\`
+ +
\`); + let block4 = createBlock(\`true\`); + let block5 = createBlock(\`owl\`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (true) { - b2 = block2(); + b4 = block4(); } else { - b3 = block3(); + b5 = block5(); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; diff --git a/tests/compiler/__snapshots__/event_handling.test.ts.snap b/tests/compiler/__snapshots__/event_handling.test.ts.snap index 72de5ff9..e7585ccc 100644 --- a/tests/compiler/__snapshots__/event_handling.test.ts.snap +++ b/tests/compiler/__snapshots__/event_handling.test.ts.snap @@ -65,23 +65,31 @@ exports[`t-on can bind handlers with empty object (with non empty inner string) let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
\`); - let block3 = createBlock(\`
  • link
  • \`); + let block3 = createBlock(\`
      + +
    \`); + let block5 = createBlock(\`
  • + link +
  • \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(['someval']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`action\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(['someval']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`action\`] = v_block4[i1]; ctx[\`action_index\`] = i1; const key1 = ctx['action_index']; const v1 = ctx['activate']; const v2 = ctx['action']; let hdlr1 = [()=>v1(v2), ctx]; - c_block2[i1] = withKey(block3([hdlr1]), key1); + c_block4[i1] = withKey(block5([hdlr1]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -106,12 +114,15 @@ exports[`t-on can bind two event handlers 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`\`); + let block3 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let hdlr1 = [ctx['handleClick'], ctx]; let hdlr2 = [ctx['handleDblClick'], ctx]; - return block1([hdlr1, hdlr2]); + const b3 = block3([hdlr1, hdlr2]); + return multi([b2, b3]); } }" `; @@ -136,18 +147,26 @@ exports[`t-on handler is bound to proper owner, part 2 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block2 = createBlock(\`\`); + let block6 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block1, v_block1, l_block1, c_block1] = prepareList([1]);; - for (let i1 = 0; i1 < l_block1; i1++) { - ctx[\`value\`] = v_block1[i1]; + const [k_block3, v_block3, l_block3, c_block3] = prepareList([1]);; + for (let i1 = 0; i1 < l_block3; i1++) { + ctx[\`value\`] = v_block3[i1]; const key1 = ctx['value']; + const b5 = text(\` + \`); let hdlr1 = [ctx['add'], ctx]; - c_block1[i1] = withKey(block2([hdlr1]), key1); + const b6 = block6([hdlr1]); + const b7 = text(\` + \`); + c_block3[i1] = withKey(multi([b5, b6, b7]), key1); } - return list(c_block1); + const b3 = list(c_block3); + return multi([b2, b3]); } }" `; @@ -186,18 +205,26 @@ exports[`t-on handler is bound to proper owner, part 4 1`] = ` const callTemplate_1 = app.getTemplate(\`sub\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block1, v_block1, l_block1, c_block1] = prepareList([1]);; - for (let i1 = 0; i1 < l_block1; i1++) { - ctx[\`value\`] = v_block1[i1]; + const [k_block3, v_block3, l_block3, c_block3] = prepareList([1]);; + for (let i1 = 0; i1 < l_block3; i1++) { + ctx[\`value\`] = v_block3[i1]; ctx[\`value_first\`] = i1 === 0; - ctx[\`value_last\`] = i1 === v_block1.length - 1; + ctx[\`value_last\`] = i1 === v_block3.length - 1; ctx[\`value_index\`] = i1; - ctx[\`value_value\`] = k_block1[i1]; + ctx[\`value_value\`] = k_block3[i1]; const key1 = ctx['value']; - c_block1[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1); + const b5 = text(\` + \`); + const b6 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); + const b7 = text(\` + \`); + c_block3[i1] = withKey(multi([b5, b6, b7]), key1); } - return list(c_block1); + const b3 = list(c_block3); + return multi([b2, b3]); } }" `; @@ -235,7 +262,9 @@ exports[`t-on t-on modifiers (native listener) basic support for native listener ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let hdlr1 = [ctx['divClicked'], ctx]; @@ -281,7 +310,9 @@ exports[`t-on t-on modifiers (native listener) t-on with .capture modifier 1`] = ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let hdlr1 = [\\"capture\\", ctx['onCapture'], ctx]; @@ -296,7 +327,9 @@ exports[`t-on t-on modifiers (native listener) t-on with empty handler (only mod ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let hdlr1 = [\\"prevent\\", , ctx]; @@ -310,7 +343,9 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent and self modifi ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let hdlr1 = [\\"prevent\\",\\"self\\", ctx['onClick'], ctx]; @@ -324,7 +359,11 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent and/or stop mod ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + + + +
    \`); return function template(ctx, node, key = \\"\\") { let hdlr1 = [\\"prevent\\", ctx['onClickPrevented'], ctx]; @@ -341,8 +380,12 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-f let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\` Edit \`); + let block1 = createBlock(\`
    + +
    \`); + let block5 = createBlock(\` + Edit + \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); @@ -350,12 +393,18 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-f for (let i1 = 0; i1 < l_block2; i1++) { ctx[\`project\`] = v_block2[i1]; const key1 = ctx['project']; + const b4 = text(\` + \`); const v1 = ctx['onEdit']; const v2 = ctx['project']; let hdlr1 = [\\"prevent\\", _ev=>v1(v2.id,_ev), ctx]; let txt1 = ctx['project'].name; - c_block2[i1] = withKey(block3([hdlr1, txt1]), key1); + const b5 = block5([hdlr1, txt1]); + const b6 = text(\` + \`); + c_block2[i1] = withKey(multi([b4, b5, b6]), key1); } + ctx = ctx.__proto__; const b2 = list(c_block2); return block1([], [b2]); } @@ -367,7 +416,9 @@ exports[`t-on t-on modifiers (native listener) t-on with self and prevent modifi ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let hdlr1 = [\\"self\\",\\"prevent\\", ctx['onClick'], ctx]; @@ -381,7 +432,10 @@ exports[`t-on t-on modifiers (native listener) t-on with self modifier 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { let hdlr1 = [ctx['onClick'], ctx]; @@ -396,7 +450,9 @@ exports[`t-on t-on modifiers (synthetic listener) basic support for synthetic 1` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let hdlr1 = [\\"synthetic\\", ctx['divClicked'], ctx]; diff --git a/tests/compiler/__snapshots__/misc.test.ts.snap b/tests/compiler/__snapshots__/misc.test.ts.snap index 4699693a..6e0b11de 100644 --- a/tests/compiler/__snapshots__/misc.test.ts.snap +++ b/tests/compiler/__snapshots__/misc.test.ts.snap @@ -7,74 +7,116 @@ exports[`misc complex template 1`] = ` let { prepareList, withKey } = helpers; const comp1 = app.createComponent(\`SlotButton\`, true, false, false, false); - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`\`); - let block3 = createBlock(\` preparing\`); - let block7 = createBlock(\`
    \`); - let block9 = createBlock(\`
    \`); - let block10 = createBlock(\`\`); - let block11 = createBlock(\`\`); - let block12 = createBlock(\`\`); - let block13 = createBlock(\`\`); + let block3 = createBlock(\`
    +
    + + +
    + + +
    +
    + +
    +
    +
    \`); + let block4 = createBlock(\`\`); + let block7 = createBlock(\` preparing\`); + let block15 = createBlock(\`
    \`); + let block17 = createBlock(\`\`); + let block18 = createBlock(\`\`); + let block19 = createBlock(\`\`); + let block20 = createBlock(\`\`); + let block21 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b2,b3,b4,b6,b8; + const b2 = text(\` + \`); + let b4,b5,b9,b14,b16; let attr1 = \`batch_tile \${ctx['options'].more?'more':'nomore'}\`; let attr2 = \`card bg-\${ctx['klass']}-light\`; let attr3 = \`/runbot/batch/\${ctx['batch'].id}\`; let attr4 = \`badge badge-\${ctx['batch'].has_warning?'warning':'light'}\`; let txt1 = ctx['batch'].formated_age; if (ctx['batch'].has_warning) { - b2 = block2(); + b4 = block4(); } if (ctx['batch'].state=='preparing') { - b3 = block3(); + const b6 = text(\` + \`); + const b7 = block7(); + const b8 = text(\` + \`); + b5 = multi([b6, b7, b8]); } ctx = Object.create(ctx); - const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['batch'].slot_ids.filter(_slot=>_slot.build_id.id&&!_slot.trigger_id.manual&&(ctx['options'].trigger_display[_slot.trigger_id.id])));; - for (let i1 = 0; i1 < l_block4; i1++) { - ctx[\`slot\`] = v_block4[i1]; + const [k_block9, v_block9, l_block9, c_block9] = prepareList(ctx['batch'].slot_ids.filter(_slot=>_slot.build_id.id&&!_slot.trigger_id.manual&&(ctx['options'].trigger_display[_slot.trigger_id.id])));; + for (let i1 = 0; i1 < l_block9; i1++) { + ctx[\`slot\`] = v_block9[i1]; const key1 = ctx['slot'].id; - c_block4[i1] = withKey(comp1({class: ctx['slot_container'],slot: ctx['slot']}, key + \`__1__\${key1}\`, node, this, null), key1); + const b11 = text(\` + \`); + const b12 = comp1({class: ctx['slot_container'],slot: ctx['slot']}, key + \`__1__\${key1}\`, node, this, null); + const b13 = text(\` + \`); + c_block9[i1] = withKey(multi([b11, b12, b13]), key1); } ctx = ctx.__proto__; - b4 = list(c_block4); + b9 = list(c_block9); ctx = Object.create(ctx); - const [k_block6, v_block6, l_block6, c_block6] = prepareList([1,2,3,4]);; - for (let i1 = 0; i1 < l_block6; i1++) { - ctx[\`x\`] = v_block6[i1]; + const [k_block14, v_block14, l_block14, c_block14] = prepareList([1,2,3,4]);; + for (let i1 = 0; i1 < l_block14; i1++) { + ctx[\`x\`] = v_block14[i1]; const key1 = ctx['x']; - c_block6[i1] = withKey(block7(), key1); + c_block14[i1] = withKey(block15(), key1); } ctx = ctx.__proto__; - b6 = list(c_block6); + b14 = list(c_block14); ctx = Object.create(ctx); - const [k_block8, v_block8, l_block8, c_block8] = prepareList(ctx['commit_links']);; - for (let i1 = 0; i1 < l_block8; i1++) { - ctx[\`commit_link\`] = v_block8[i1]; + const [k_block16, v_block16, l_block16, c_block16] = prepareList(ctx['commit_links']);; + for (let i1 = 0; i1 < l_block16; i1++) { + ctx[\`commit_link\`] = v_block16[i1]; const key1 = ctx['commit_link'].id; - let b10,b11,b12,b13; + let b18,b19,b20,b21; 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') { - b10 = block10(); + b18 = block18(); } if (ctx['commit_link'].match_type=='head') { - b11 = block11(); + b19 = block19(); } if (ctx['commit_link'].match_type=='base_match') { - b12 = block12(); + b20 = block20(); } if (ctx['commit_link'].match_type=='base_head') { - b13 = block13(); + b21 = block21(); } let txt2 = ctx['commit_link'].commit_dname; let attr7 = 'https://%s/commit/%s'%(ctx['commit_link'].commit_remote_url,ctx['commit_link'].commit_name); let txt3 = ctx['commit_link'].commit_subject; - c_block8[i1] = withKey(block9([attr5, attr6, txt2, attr7, txt3], [b10, b11, b12, b13]), key1); + c_block16[i1] = withKey(block17([attr5, attr6, txt2, attr7, txt3], [b18, b19, b20, b21]), key1); } - b8 = list(c_block8); - return block1([attr1, attr2, attr3, attr4, txt1], [b2, b3, b4, b6, b8]); + ctx = ctx.__proto__; + b16 = list(c_block16); + const b3 = block3([attr1, attr2, attr3, attr4, txt1], [b4, b5, b9, b14, b16]); + return multi([b2, b3]); } }" `; @@ -90,43 +132,71 @@ exports[`misc global 1`] = ` const callTemplate_4 = app.getTemplate(\`_callee-asc\`); const callTemplate_5 = app.getTemplate(\`_callee-asc-toto\`); - let block1 = createBlock(\`
    \`); - let block4 = createBlock(\`\`); + let block3 = createBlock(\`
    + + +
    \`); + let block7 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList([4,5,6]);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`value\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList([4,5,6]);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`value\`] = v_block4[i1]; ctx[\`value_first\`] = i1 === 0; - ctx[\`value_last\`] = i1 === v_block2.length - 1; + ctx[\`value_last\`] = i1 === v_block4.length - 1; ctx[\`value_index\`] = i1; - ctx[\`value_value\`] = k_block2[i1]; + ctx[\`value_value\`] = k_block4[i1]; const key1 = ctx['value']; + const b6 = text(\` + \`); let txt1 = ctx['value']; - const b4 = block4([txt1]); + const b7 = block7([txt1]); + const b8 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b10 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b12 = text(\` + \`); setContextValue(ctx, \\"foo\\", 'aaa'); - const b6 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); + const b13 = text(\` + \`); + const b11 = multi([b12, b13]); + ctx[zero] = b11; + const b14 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); ctx = ctx.__proto__; - const b7 = callTemplate_2.call(this, ctx, node, key + \`__2__\${key1}\`); + const b15 = text(\` + \`); + const b16 = callTemplate_2.call(this, ctx, node, key + \`__2__\${key1}\`); + const b17 = text(\` + \`); setContextValue(ctx, \\"foo\\", 'bbb'); - const b8 = callTemplate_3.call(this, ctx, node, key + \`__3__\${key1}\`); - const b5 = multi([b6, b7, b8]); - ctx[zero] = b5; - const b9 = callTemplate_4.call(this, ctx, node, key + \`__4__\${key1}\`); + const b18 = text(\` + \`); + const b19 = callTemplate_3.call(this, ctx, node, key + \`__3__\${key1}\`); + const b20 = text(\` + \`); + const b9 = multi([b10, b14, b15, b16, b17, b18, b19, b20]); + ctx[zero] = b9; + const b21 = callTemplate_4.call(this, ctx, node, key + \`__4__\${key1}\`); ctx = ctx.__proto__; - c_block2[i1] = withKey(multi([b4, b9]), key1); + const b22 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b8, b21, b22]), key1); } ctx = ctx.__proto__; - const b2 = list(c_block2); - const b10 = callTemplate_5.call(this, ctx, node, key + \`__5\`); - return block1([], [b2, b10]); + const b4 = list(c_block4); + const b23 = callTemplate_5.call(this, ctx, node, key + \`__5\`); + const b3 = block3([], [b4, b23]); + return multi([b2, b3]); } }" `; @@ -187,7 +257,48 @@ exports[`misc other complex template 1`] = ` const comp1 = app.createComponent(\`BundlesList\`, true, false, false, false); const comp2 = app.createComponent(\`BundlesList\`, true, false, false, false); - let block1 = createBlock(\`
    Triggers
    \`); - let block3 = createBlock(\`
  • \`); - let block5 = createBlock(\`
  • Login
  • \`); - let block8 = createBlock(\`
  • \`); - let block9 = createBlock(\`
  • \`); - let block11 = createBlock(\`
  • \`); - let block12 = createBlock(\`
  • \`); - let block13 = createBlock(\`
  • \`); - let block14 = createBlock(\`\`); - let block16 = createBlock(\`\`); - let block20 = createBlock(\`
    \`); - let block21 = createBlock(\`
    \`); - let block23 = createBlock(\`
    \`); - let block24 = createBlock(\`

    No project

    \`); - let block25 = createBlock(\`
    \`); + +
    +
    Triggers
    + +
    +
    +
    + +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    \`); + let block5 = createBlock(\`
  • + + + +
  • \`); + let block10 = createBlock(\`
  • + + Login + +
  • \`); + let block16 = createBlock(\`
  • + + + +
  • \`); + let block18 = createBlock(\`
  • \`); + let block22 = createBlock(\`
  • + +
  • \`); + let block24 = createBlock(\`
  • \`); + let block27 = createBlock(\`
  • + + + + + +
    + Logout + Web +
    +
  • \`); + let block30 = createBlock(\`\`); + let block32 = createBlock(\`\`); + let block38 = createBlock(\`
    + + +
    \`); + let block41 = createBlock(\`
    + + + + +
    \`); + let block44 = createBlock(\`
    + +
    \`); + let block45 = createBlock(\`
    +

    No project

    +
    \`); + let block46 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { const refs = ctx.__owl__.refs; const ref1 = (el) => refs[\`search_input\`] = el; const ref2 = (el) => refs[\`settings_menu\`] = el; - let b2,b4,b14,b17,b22,b23,b24,b25; + const b2 = text(\` + \`); + let b4,b6,b30,b33,b43,b44,b45,b46; let attr1 = \`/runbot/\${ctx['project'].slug}\`; let txt1 = ctx['project'].name; ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['projects']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`project\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['projects']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`project\`] = v_block4[i1]; const key1 = ctx['project'].id; let hdlr1 = [ctx['selectProject'](ctx['project']), ctx]; let txt2 = ctx['project'].name; - c_block2[i1] = withKey(block3([hdlr1, txt2]), key1); + c_block4[i1] = withKey(block5([hdlr1, txt2]), key1); } ctx = ctx.__proto__; - b2 = list(c_block2); + b4 = list(c_block4); if (ctx['user']) { - let b5,b6; + let b7,b8,b12,b29; + b7 = text(\` + \`); if (ctx['user'].public) { + const b9 = text(\` + \`); let attr2 = \`/web/login?redirect=/\`; - b5 = block5([attr2]); + const b10 = block10([attr2]); + const b11 = text(\` + \`); + b8 = multi([b9, b10, b11]); } else { - let b7,b10,b13; + let b13,b14,b20,b26,b27,b28; + b13 = text(\` + \`); if (ctx['nb_assigned_errors']&&ctx['nb_assigned_errors']>0) { + const b15 = text(\` + \`); let attr3 = \`You have \${ctx['nb_assigned_errors']} random bug assigned\`; let txt3 = ctx['nb_assigned_errors']; - const b8 = block8([attr3, txt3]); - const b9 = block9(); - b7 = multi([b8, b9]); + const b16 = block16([attr3, txt3]); + const b17 = text(\` + \`); + const b18 = block18(); + const b19 = text(\` + \`); + b14 = multi([b15, b16, b17, b18, b19]); } else if (ctx['nb_build_errors']&&ctx['nb_build_errors']>0) { - const b11 = block11(); - const b12 = block12(); - b10 = multi([b11, b12]); + const b21 = text(\` + \`); + const b22 = block22(); + const b23 = text(\` + \`); + const b24 = block24(); + const b25 = text(\` + \`); + b20 = multi([b21, b22, b23, b24, b25]); } + b26 = text(\` + \`); let txt4 = ctx['user'].name.length>25?ctx['user'].namesubstring(0,23)+'...':ctx['user'].name; let attr4 = \`/web/session/logout?redirect=/\`; let attr5 = \`/web\`; - b13 = block13([txt4, attr4, attr5]); - b6 = multi([b7, b10, b13]); + b27 = block27([txt4, attr4, attr5]); + b28 = text(\` + \`); + b12 = multi([b13, b14, b20, b26, b27, b28]); } - b4 = multi([b5, b6]); + b29 = text(\` + \`); + b6 = multi([b7, b8, b12, b29]); } let hdlr2 = [ctx['toggleSettingsMenu'], ctx]; let hdlr3 = [ctx['toggleMore'], ctx]; if (ctx['categories']&&ctx['categories'].length>1) { ctx = Object.create(ctx); - const [k_block15, v_block15, l_block15, c_block15] = prepareList(ctx['categories']);; - for (let i1 = 0; i1 < l_block15; i1++) { - ctx[\`category\`] = v_block15[i1]; + const [k_block31, v_block31, l_block31, c_block31] = prepareList(ctx['categories']);; + for (let i1 = 0; i1 < l_block31; i1++) { + ctx[\`category\`] = v_block31[i1]; const key1 = ctx['category'].id; let attr6 = ctx['category'].id; let attr7 = ctx['category'].id==ctx['options'].active_category_id; let txt5 = ctx['category'].name; - c_block15[i1] = withKey(block16([attr6, attr7, txt5]), key1); + c_block31[i1] = withKey(block32([attr6, attr7, txt5]), key1); } ctx = ctx.__proto__; - const b15 = list(c_block15); - b14 = block14([], [b15]); + const b31 = list(c_block31); + b30 = block30([], [b31]); } let attr8 = ctx['search'].value; let hdlr4 = [ctx['updateFilter'], ctx]; let hdlr5 = [ctx['updateFilter'], ctx]; let hdlr6 = [ctx['clearSearch'], ctx]; if (ctx['triggers']) { + const b34 = text(\` + \`); ctx = Object.create(ctx); - const [k_block18, v_block18, l_block18, c_block18] = prepareList(ctx['triggers']);; - for (let i1 = 0; i1 < l_block18; i1++) { - ctx[\`trigger\`] = v_block18[i1]; + const [k_block35, v_block35, l_block35, c_block35] = prepareList(ctx['triggers']);; + for (let i1 = 0; i1 < l_block35; i1++) { + ctx[\`trigger\`] = v_block35[i1]; const key1 = ctx['trigger'].id; - let b20; + let b37,b38,b39; + b37 = text(\` + \`); if (!ctx['trigger'].manual&&ctx['trigger'].project_id===ctx['project'].id&&ctx['trigger'].category_id===ctx['options'].active_category_id) { let attr9 = \`trigger_\${ctx['trigger'].id}\`; let attr10 = \`trigger_\${ctx['trigger'].id}\`; @@ -296,34 +500,41 @@ exports[`misc other complex template 1`] = ` let hdlr7 = [ctx['updateTriggerDisplay'], ctx]; let attr13 = \`trigger_\${ctx['trigger'].id}\`; let txt6 = ctx['trigger'].name; - b20 = block20([attr9, attr10, attr11, attr12, hdlr7, attr13, txt6]); + b38 = block38([attr9, attr10, attr11, attr12, hdlr7, attr13, txt6]); } - c_block18[i1] = withKey(multi([b20]), key1); + b39 = text(\` + \`); + c_block35[i1] = withKey(multi([b37, b38, b39]), key1); } ctx = ctx.__proto__; - const b18 = list(c_block18); + const b35 = list(c_block35); + const b40 = text(\` + \`); let hdlr8 = [ctx['triggerAll'], ctx]; let hdlr9 = [ctx['triggerNone'], ctx]; let hdlr10 = [ctx['triggerDefault'], ctx]; let hdlr11 = [ctx['toggleSettingsMenu'], ctx]; - const b21 = block21([hdlr8, hdlr9, hdlr10, hdlr11]); - b17 = multi([b18, b21]); + const b41 = block41([hdlr8, hdlr9, hdlr10, hdlr11]); + const b42 = text(\` + \`); + b33 = multi([b34, b35, b40, b41, b42]); } if (ctx['load_infos']) { - b22 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + b43 = callTemplate_1.call(this, ctx, node, key + \`__1\`); } if (ctx['message']) { let txt7 = ctx['message']; - b23 = block23([txt7]); + b44 = block44([txt7]); } if (!ctx['project']) { - b24 = block24(); + b45 = block45(); } else { - const b26 = comp1({bundles: ctx['bundles'].sticky,category_custom_views: ctx['category_custom_views'],search: ctx['search']}, key + \`__2\`, node, this, null); - const b27 = comp2({bundles: ctx['bundles'].dev,search: ctx['search']}, key + \`__3\`, node, this, null); - b25 = block25([], [b26, b27]); + const b47 = comp1({bundles: ctx['bundles'].sticky,category_custom_views: ctx['category_custom_views'],search: ctx['search']}, key + \`__2\`, node, this, null); + const b48 = comp2({bundles: ctx['bundles'].dev,search: ctx['search']}, key + \`__3\`, node, this, null); + b46 = block46([], [b47, b48]); } - return block1([attr1, txt1, hdlr2, hdlr3, attr8, hdlr4, hdlr5, ref1, hdlr6, ref2], [b2, b4, b14, b17, b22, b23, b24, b25]); + const b3 = block3([attr1, txt1, hdlr2, hdlr3, attr8, hdlr4, hdlr5, ref1, hdlr6, ref2], [b4, b6, b30, b33, b43, b44, b45, b46]); + return multi([b2, b3]); } }" `; diff --git a/tests/compiler/__snapshots__/simple_templates.test.ts.snap b/tests/compiler/__snapshots__/simple_templates.test.ts.snap index e6e75add..aa61fb1d 100644 --- a/tests/compiler/__snapshots__/simple_templates.test.ts.snap +++ b/tests/compiler/__snapshots__/simple_templates.test.ts.snap @@ -313,13 +313,22 @@ exports[`simple templates, mostly static template with multiple t tag with multi ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    Loading
    \`); + let block3 = createBlock(\`
    + + + + Loading + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['a']; let txt2 = ctx['b']; let txt3 = ctx['c']; - return block1([txt1, txt2, txt3]); + const b3 = block3([txt1, txt2, txt3]); + return multi([b2, b3]); } }" `; diff --git a/tests/compiler/__snapshots__/svg.test.ts.snap b/tests/compiler/__snapshots__/svg.test.ts.snap index f8c71063..dd6afaaf 100644 --- a/tests/compiler/__snapshots__/svg.test.ts.snap +++ b/tests/compiler/__snapshots__/svg.test.ts.snap @@ -57,17 +57,27 @@ exports[`properly support svg svg creates new block if it is within html -- 2 1` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`\`); - let block3 = createBlock(\`\`); + let block3 = createBlock(\`
    + +
    \`); + let block4 = createBlock(\` + + + \`); + let block5 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { - let b3; + const b2 = text(\` + \`); + let b5; if (ctx['hasPath']) { - b3 = block3(); + b5 = block5(); } - const b2 = block2([], [b3]); - return block1([], [b2]); + const b4 = block4([], [b5]); + const b3 = block3([], [b4]); + const b6 = text(\` + \`); + return multi([b2, b3, b6]); } }" `; @@ -77,12 +87,21 @@ exports[`properly support svg svg creates new block if it is within html 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`\`); + let block3 = createBlock(\`
    + +
    \`); + let block4 = createBlock(\` + + \`); return function template(ctx, node, key = \\"\\") { - const b2 = block2(); - return block1([], [b2]); + const b2 = text(\` + \`); + const b4 = block4(); + const b3 = block3([], [b4]); + const b5 = text(\` + \`); + return multi([b2, b3, b5]); } }" `; diff --git a/tests/compiler/__snapshots__/t_call.test.ts.snap b/tests/compiler/__snapshots__/t_call.test.ts.snap index 148914da..d34df1ac 100644 --- a/tests/compiler/__snapshots__/t_call.test.ts.snap +++ b/tests/compiler/__snapshots__/t_call.test.ts.snap @@ -60,20 +60,30 @@ exports[`t-call (template calling) call with several sub nodes on same line 1`] let { isBoundary, zero } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`hey\`); - let block5 = createBlock(\`yay\`); + let block3 = createBlock(\`
    + +
    \`); + let block6 = createBlock(\`hey\`); + let block8 = createBlock(\`yay\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; - const b3 = block3(); - const b4 = text(\` \`); - const b5 = block5(); - const b2 = multi([b3, b4, b5]); - ctx[zero] = b2; - const b6 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b6]); + const b5 = text(\` + \`); + const b6 = block6(); + const b7 = text(\` \`); + const b8 = block8(); + const b9 = text(\` + \`); + const b4 = multi([b5, b6, b7, b8, b9]); + ctx[zero] = b4; + const b10 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b10]); + return multi([b2, b3]); } }" `; @@ -84,11 +94,16 @@ exports[`t-call (template calling) call with several sub nodes on same line 2`] let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { zero } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - const b2 = ctx[zero]; - return block1([], [b2]); + const b2 = text(\` + \`); + const b4 = ctx[zero]; + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -100,20 +115,30 @@ exports[`t-call (template calling) cascading t-call t-out='0' 1`] = ` let { isBoundary, zero } = helpers; const callTemplate_1 = app.getTemplate(\`subTemplate\`); - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`hey\`); - let block5 = createBlock(\`yay\`); + let block3 = createBlock(\`
    + +
    \`); + let block6 = createBlock(\`hey\`); + let block8 = createBlock(\`yay\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; - const b3 = block3(); - const b4 = text(\` \`); - const b5 = block5(); - const b2 = multi([b3, b4, b5]); - ctx[zero] = b2; - const b6 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b6]); + const b5 = text(\` + \`); + const b6 = block6(); + const b7 = text(\` \`); + const b8 = block8(); + const b9 = text(\` + \`); + const b4 = multi([b5, b6, b7, b8, b9]); + ctx[zero] = b4; + const b10 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b10]); + return multi([b2, b3]); } }" `; @@ -125,18 +150,30 @@ exports[`t-call (template calling) cascading t-call t-out='0' 2`] = ` let { isBoundary, zero } = helpers; const callTemplate_1 = app.getTemplate(\`subSubTemplate\`); - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`cascade 0\`); + let block3 = createBlock(\`
    + +
    \`); + let block6 = createBlock(\`cascade 0\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; - const b3 = block3(); - const b4 = ctx[zero]; - const b2 = multi([b3, b4]); - ctx[zero] = b2; - const b5 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b5]); + const b5 = text(\` + \`); + const b6 = block6(); + const b7 = text(\` + \`); + const b8 = ctx[zero]; + const b9 = text(\` + \`); + const b4 = multi([b5, b6, b7, b8, b9]); + ctx[zero] = b4; + const b10 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b10]); + return multi([b2, b3]); } }" `; @@ -148,18 +185,30 @@ exports[`t-call (template calling) cascading t-call t-out='0' 3`] = ` let { isBoundary, zero } = helpers; const callTemplate_1 = app.getTemplate(\`finalTemplate\`); - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`cascade 1\`); + let block3 = createBlock(\`
    + +
    \`); + let block6 = createBlock(\`cascade 1\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; - const b3 = block3(); - const b4 = ctx[zero]; - const b2 = multi([b3, b4]); - ctx[zero] = b2; - const b5 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b5]); + const b5 = text(\` + \`); + const b6 = block6(); + const b7 = text(\` + \`); + const b8 = ctx[zero]; + const b9 = text(\` + \`); + const b4 = multi([b5, b6, b7, b8, b9]); + ctx[zero] = b4; + const b10 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b10]); + return multi([b2, b3]); } }" `; @@ -170,11 +219,17 @@ exports[`t-call (template calling) cascading t-call t-out='0' 4`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { zero } = helpers; - let block1 = createBlock(\`
    cascade 2
    \`); + let block3 = createBlock(\`
    + cascade 2 + +
    \`); return function template(ctx, node, key = \\"\\") { - const b2 = ctx[zero]; - return block1([], [b2]); + const b2 = text(\` + \`); + const b4 = ctx[zero]; + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -186,18 +241,25 @@ exports[`t-call (template calling) cascading t-call t-out='0', without external let { isBoundary, zero } = helpers; const callTemplate_1 = app.getTemplate(\`subTemplate\`); - let block2 = createBlock(\`hey\`); - let block4 = createBlock(\`yay\`); + let block5 = createBlock(\`hey\`); + let block7 = createBlock(\`yay\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; - const b2 = block2(); - const b3 = text(\` \`); - const b4 = block4(); - const b1 = multi([b2, b3, b4]); - ctx[zero] = b1; - return callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b4 = text(\` + \`); + const b5 = block5(); + const b6 = text(\` \`); + const b7 = block7(); + const b8 = text(\` + \`); + const b3 = multi([b4, b5, b6, b7, b8]); + ctx[zero] = b3; + const b9 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + return multi([b2, b9]); } }" `; @@ -209,16 +271,25 @@ exports[`t-call (template calling) cascading t-call t-out='0', without external let { isBoundary, zero } = helpers; const callTemplate_1 = app.getTemplate(\`subSubTemplate\`); - let block2 = createBlock(\`cascade 0\`); + let block5 = createBlock(\`cascade 0\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; - const b2 = block2(); - const b3 = ctx[zero]; - const b1 = multi([b2, b3]); - ctx[zero] = b1; - return callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b4 = text(\` + \`); + const b5 = block5(); + const b6 = text(\` + \`); + const b7 = ctx[zero]; + const b8 = text(\` + \`); + const b3 = multi([b4, b5, b6, b7, b8]); + ctx[zero] = b3; + const b9 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + return multi([b2, b9]); } }" `; @@ -230,16 +301,25 @@ exports[`t-call (template calling) cascading t-call t-out='0', without external let { isBoundary, zero } = helpers; const callTemplate_1 = app.getTemplate(\`finalTemplate\`); - let block2 = createBlock(\`cascade 1\`); + let block5 = createBlock(\`cascade 1\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; - const b2 = block2(); - const b3 = ctx[zero]; - const b1 = multi([b2, b3]); - ctx[zero] = b1; - return callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b4 = text(\` + \`); + const b5 = block5(); + const b6 = text(\` + \`); + const b7 = ctx[zero]; + const b8 = text(\` + \`); + const b3 = multi([b4, b5, b6, b7, b8]); + ctx[zero] = b3; + const b9 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + return multi([b2, b9]); } }" `; @@ -250,12 +330,16 @@ exports[`t-call (template calling) cascading t-call t-out='0', without external let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { zero } = helpers; - let block2 = createBlock(\`cascade 2\`); + let block3 = createBlock(\`cascade 2\`); return function template(ctx, node, key = \\"\\") { - const b2 = block2(); - const b3 = ctx[zero]; - return multi([b2, b3]); + const b2 = text(\` + \`); + const b3 = block3(); + const b4 = text(\` + \`); + const b5 = ctx[zero]; + return multi([b2, b3, b4, b5]); } }" `; @@ -340,14 +424,25 @@ exports[`t-call (template calling) recursive template, part 1 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const callTemplate_1 = app.getTemplate(\`recursive\`); - let block1 = createBlock(\`
    hey
    \`); + let block3 = createBlock(\`
    + hey + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2; + const b2 = text(\` + \`); + let b4; if (false) { - b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b5 = text(\` + \`); + const b6 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b7 = text(\` + \`); + b4 = multi([b5, b6, b7]); } - return block1([], [b2]); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -356,19 +451,31 @@ exports[`t-call (template calling) recursive template, part 2 1`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`nodeTemplate\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b5 = text(\` + \`); setContextValue(ctx, \\"node\\", ctx['root']); - const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b2]); + const b6 = text(\` + \`); + const b4 = multi([b5, b6]); + ctx[zero] = b4; + const b7 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b7]); + return multi([b2, b3]); } }" `; @@ -377,32 +484,50 @@ exports[`t-call (template calling) recursive template, part 2 2`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { prepareList, isBoundary, withDefault, setContextValue, withKey } = helpers; + let { prepareList, isBoundary, withDefault, setContextValue, zero, withKey } = helpers; const callTemplate_1 = app.getTemplate(\`nodeTemplate\`); - let block1 = createBlock(\`

    \`); + let block3 = createBlock(\`
    +

    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); let txt1 = ctx['node'].val; ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['node'].children||[]);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`subtree\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['node'].children||[]);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`subtree\`] = v_block4[i1]; ctx[\`subtree_first\`] = i1 === 0; - ctx[\`subtree_last\`] = i1 === v_block2.length - 1; + ctx[\`subtree_last\`] = i1 === v_block4.length - 1; ctx[\`subtree_index\`] = i1; - ctx[\`subtree_value\`] = k_block2[i1]; + ctx[\`subtree_value\`] = k_block4[i1]; const key1 = ctx['subtree_index']; + const b6 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b8 = text(\` + \`); setContextValue(ctx, \\"node\\", ctx['subtree']); - c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1); + const b9 = text(\` + \`); + const b7 = multi([b8, b9]); + ctx[zero] = b7; + const b10 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); ctx = ctx.__proto__; + const b11 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b10, b11]), key1); } - const b2 = list(c_block2); - return block1([txt1], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([txt1], [b4]); + return multi([b2, b3]); } }" `; @@ -411,19 +536,31 @@ exports[`t-call (template calling) recursive template, part 3 1`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`nodeTemplate\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b5 = text(\` + \`); setContextValue(ctx, \\"node\\", ctx['root']); - const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b2]); + const b6 = text(\` + \`); + const b4 = multi([b5, b6]); + ctx[zero] = b4; + const b7 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b7]); + return multi([b2, b3]); } }" `; @@ -432,32 +569,50 @@ exports[`t-call (template calling) recursive template, part 3 2`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { prepareList, isBoundary, withDefault, setContextValue, withKey } = helpers; + let { prepareList, isBoundary, withDefault, setContextValue, zero, withKey } = helpers; const callTemplate_1 = app.getTemplate(\`nodeTemplate\`); - let block1 = createBlock(\`

    \`); + let block3 = createBlock(\`
    +

    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); let txt1 = ctx['node'].val; ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['node'].children||[]);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`subtree\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['node'].children||[]);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`subtree\`] = v_block4[i1]; ctx[\`subtree_first\`] = i1 === 0; - ctx[\`subtree_last\`] = i1 === v_block2.length - 1; + ctx[\`subtree_last\`] = i1 === v_block4.length - 1; ctx[\`subtree_index\`] = i1; - ctx[\`subtree_value\`] = k_block2[i1]; + ctx[\`subtree_value\`] = k_block4[i1]; const key1 = ctx['subtree_index']; + const b6 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b8 = text(\` + \`); setContextValue(ctx, \\"node\\", ctx['subtree']); - c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1); + const b9 = text(\` + \`); + const b7 = multi([b8, b9]); + ctx[zero] = b7; + const b10 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); ctx = ctx.__proto__; + const b11 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b10, b11]), key1); } - const b2 = list(c_block2); - return block1([txt1], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([txt1], [b4]); + return multi([b2, b3]); } }" `; @@ -466,20 +621,34 @@ exports[`t-call (template calling) recursive template, part 4: with t-set recurs "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`nodeTemplate\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b5 = text(\` + \`); setContextValue(ctx, \\"recursive_idx\\", 1); + const b6 = text(\` + \`); setContextValue(ctx, \\"node\\", ctx['root']); - const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b2]); + const b7 = text(\` + \`); + const b4 = multi([b5, b6, b7]); + ctx[zero] = b4; + const b8 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b8]); + return multi([b2, b3]); } }" `; @@ -488,34 +657,53 @@ exports[`t-call (template calling) recursive template, part 4: with t-set recurs "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; + let { isBoundary, withDefault, setContextValue, prepareList, zero, withKey } = helpers; const callTemplate_1 = app.getTemplate(\`nodeTemplate\`); - let block1 = createBlock(\`

    \`); + let block3 = createBlock(\`
    + +

    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"recursive_idx\\", ctx['recursive_idx']+1); let txt1 = ctx['node'].val; let txt2 = ctx['recursive_idx']; ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['node'].children||[]);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`subtree\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['node'].children||[]);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`subtree\`] = v_block4[i1]; ctx[\`subtree_first\`] = i1 === 0; - ctx[\`subtree_last\`] = i1 === v_block2.length - 1; + ctx[\`subtree_last\`] = i1 === v_block4.length - 1; ctx[\`subtree_index\`] = i1; - ctx[\`subtree_value\`] = k_block2[i1]; + ctx[\`subtree_value\`] = k_block4[i1]; const key1 = ctx['subtree_index']; + const b6 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b8 = text(\` + \`); setContextValue(ctx, \\"node\\", ctx['subtree']); - c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1); + const b9 = text(\` + \`); + const b7 = multi([b8, b9]); + ctx[zero] = b7; + const b10 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); ctx = ctx.__proto__; + const b11 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b10, b11]), key1); } - const b2 = list(c_block2); - return block1([txt1, txt2], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([txt1, txt2], [b4]); + return multi([b2, b3]); } }" `; @@ -524,21 +712,33 @@ exports[`t-call (template calling) scoped parameters 1`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b5 = text(\` + \`); setContextValue(ctx, \\"foo\\", 42); - const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b6 = text(\` + \`); + const b4 = multi([b5, b6]); + ctx[zero] = b4; + const b7 = callTemplate_1.call(this, ctx, node, key + \`__1\`); ctx = ctx.__proto__; let txt1 = ctx['foo']; - return block1([txt1], [b2]); + const b3 = block3([txt1], [b7]); + return multi([b2, b3]); } }" `; @@ -558,22 +758,35 @@ exports[`t-call (template calling) scoped parameters, part 2 1`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"foo\\", 11); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b5 = text(\` + \`); setContextValue(ctx, \\"foo\\", 42); - const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b6 = text(\` + \`); + const b4 = multi([b5, b6]); + ctx[zero] = b4; + const b7 = callTemplate_1.call(this, ctx, node, key + \`__1\`); ctx = ctx.__proto__; let txt1 = ctx['foo']; - return block1([txt1], [b2]); + const b3 = block3([txt1], [b7]); + return multi([b2, b3]); } }" `; @@ -716,19 +929,31 @@ exports[`t-call (template calling) t-call with t-set inside and body text conten "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b5 = text(\` + \`); setContextValue(ctx, \\"val\\", \`yip yip\`); - const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b2]); + const b6 = text(\` + \`); + const b4 = multi([b5, b6]); + ctx[zero] = b4; + const b7 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b7]); + return multi([b2, b3]); } }" `; @@ -751,32 +976,51 @@ exports[`t-call (template calling) t-call with t-set inside and outside 1`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { prepareList, isBoundary, withDefault, setContextValue, withKey } = helpers; + let { prepareList, isBoundary, withDefault, setContextValue, zero, withKey } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['list']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`v\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['list']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`v\`] = v_block4[i1]; ctx[\`v_first\`] = i1 === 0; - ctx[\`v_last\`] = i1 === v_block2.length - 1; + ctx[\`v_last\`] = i1 === v_block4.length - 1; ctx[\`v_index\`] = i1; - ctx[\`v_value\`] = k_block2[i1]; + ctx[\`v_value\`] = k_block4[i1]; const key1 = ctx['v_index']; + const b6 = text(\` + \`); setContextValue(ctx, \\"val\\", ctx['v'].val); + const b7 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b9 = text(\` + \`); setContextValue(ctx, \\"val3\\", ctx['val']*3); - c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1); + const b10 = text(\` + \`); + const b8 = multi([b9, b10]); + ctx[zero] = b8; + const b11 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); ctx = ctx.__proto__; + const b12 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b11, b12]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -786,11 +1030,18 @@ exports[`t-call (template calling) t-call with t-set inside and outside 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`\`); + let block4 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); + const b3 = text(\` + \`); let txt1 = ctx['val3']; - return block1([txt1]); + const b4 = block4([txt1]); + const b5 = text(\` + \`); + return multi([b2, b3, b4, b5]); } }" `; @@ -818,32 +1069,51 @@ exports[`t-call (template calling) t-call with t-set inside and outside. 2 2`] = "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { prepareList, isBoundary, withDefault, setContextValue, withKey } = helpers; + let { prepareList, isBoundary, withDefault, setContextValue, zero, withKey } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['list']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`v\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['list']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`v\`] = v_block4[i1]; ctx[\`v_first\`] = i1 === 0; - ctx[\`v_last\`] = i1 === v_block2.length - 1; + ctx[\`v_last\`] = i1 === v_block4.length - 1; ctx[\`v_index\`] = i1; - ctx[\`v_value\`] = k_block2[i1]; + ctx[\`v_value\`] = k_block4[i1]; const key1 = ctx['v_index']; + const b6 = text(\` + \`); setContextValue(ctx, \\"val\\", ctx['v'].val); + const b7 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b9 = text(\` + \`); setContextValue(ctx, \\"val3\\", ctx['val']*3); - c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1); + const b10 = text(\` + \`); + const b8 = multi([b9, b10]); + ctx[zero] = b8; + const b11 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`); ctx = ctx.__proto__; + const b12 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b11, b12]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -853,13 +1123,21 @@ exports[`t-call (template calling) t-call with t-set inside and outside. 2 3`] = ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block2 = createBlock(\`\`); + let block4 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); + const b3 = text(\` + \`); let txt1 = ctx['val3']; - const b2 = block2([txt1]); - const b3 = text(ctx['w']); - return multi([b2, b3]); + const b4 = block4([txt1]); + const b5 = text(\` + \`); + const b6 = text(ctx['w']); + const b7 = text(\` + \`); + return multi([b2, b3, b4, b5, b6, b7]); } }" `; @@ -868,27 +1146,39 @@ exports[`t-call (template calling) t-call, conditional and t-set in t-call body "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`callee1\`); const callTemplate_2 = app.getTemplate(\`callee2\`); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - let b2,b3; + const b2 = text(\` + \`); + let b4,b8; setContextValue(ctx, \\"v1\\", 'elif'); if (ctx['v1']==='if') { - b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + b4 = callTemplate_1.call(this, ctx, node, key + \`__1\`); } else if (ctx['v1']==='elif') { ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b6 = text(\` + \`); setContextValue(ctx, \\"v\\", 'success'); - b3 = callTemplate_2.call(this, ctx, node, key + \`__2\`); + const b7 = text(\` + \`); + const b5 = multi([b6, b7]); + ctx[zero] = b5; + b8 = callTemplate_2.call(this, ctx, node, key + \`__2\`); ctx = ctx.__proto__; } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b8]); + return multi([b2, b3]); } }" `; @@ -951,17 +1241,26 @@ exports[`t-call (template calling) t-call-context and value in body 1`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); let ctx1 = ctx['obj']; ctx1 = Object.create(ctx1); ctx1[isBoundary] = 1; - setContextValue(ctx1, \\"value2\\", ctx['aaron']); - return callTemplate_1.call(this, ctx1, node, key + \`__1\`); + const b4 = text(\` + \`); + setContextValue(ctx, \\"value2\\", ctx['aaron']); + const b5 = text(\` + \`); + const b3 = multi([b4, b5]); + ctx1[zero] = b3; + const b6 = callTemplate_1.call(this, ctx1, node, key + \`__1\`); + return multi([b2, b6]); } }" `; diff --git a/tests/compiler/__snapshots__/t_debug_log.test.ts.snap b/tests/compiler/__snapshots__/t_debug_log.test.ts.snap index 58899b6a..e2db3426 100644 --- a/tests/compiler/__snapshots__/t_debug_log.test.ts.snap +++ b/tests/compiler/__snapshots__/t_debug_log.test.ts.snap @@ -55,7 +55,10 @@ exports[`debugging t-log 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); diff --git a/tests/compiler/__snapshots__/t_esc.test.ts.snap b/tests/compiler/__snapshots__/t_esc.test.ts.snap index b264b276..e73daaa5 100644 --- a/tests/compiler/__snapshots__/t_esc.test.ts.snap +++ b/tests/compiler/__snapshots__/t_esc.test.ts.snap @@ -5,15 +5,24 @@ exports[`t-esc div with falsy values 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`

    \`); + let block3 = createBlock(\`
    +

    +

    +

    +

    +

    +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['v1']; let txt2 = ctx['v2']; let txt3 = ctx['v3']; let txt4 = ctx['v4']; let txt5 = ctx['v5']; - return block1([txt1, txt2, txt3, txt4, txt5]); + const b3 = block3([txt1, txt2, txt3, txt4, txt5]); + return multi([b2, b3]); } }" `; @@ -82,16 +91,18 @@ exports[`t-esc falsy values in text nodes 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; return function template(ctx, node, key = \\"\\") { - const b2 = text(ctx['v1']); - const b3 = text(\`:\`); - const b4 = text(ctx['v2']); - const b5 = text(\`:\`); - const b6 = text(ctx['v3']); - const b7 = text(\`:\`); - const b8 = text(ctx['v4']); - const b9 = text(\`:\`); - const b10 = text(ctx['v5']); - return multi([b2, b3, b4, b5, b6, b7, b8, b9, b10]); + const b2 = text(\` + \`); + const b3 = text(ctx['v1']); + const b4 = text(\`:\`); + const b5 = text(ctx['v2']); + const b6 = text(\`:\`); + const b7 = text(ctx['v3']); + const b8 = text(\`:\`); + const b9 = text(ctx['v4']); + const b10 = text(\`:\`); + const b11 = text(ctx['v5']); + return multi([b2, b3, b4, b5, b6, b7, b8, b9, b10, b11]); } }" `; diff --git a/tests/compiler/__snapshots__/t_foreach.test.ts.snap b/tests/compiler/__snapshots__/t_foreach.test.ts.snap index 3ec3c63c..d99cb447 100644 --- a/tests/compiler/__snapshots__/t_foreach.test.ts.snap +++ b/tests/compiler/__snapshots__/t_foreach.test.ts.snap @@ -6,18 +6,24 @@ exports[`t-foreach does not pollute the rendering context 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList([1]);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`item\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList([1]);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`item\`] = v_block4[i1]; const key1 = ctx['item']; - c_block2[i1] = withKey(text(ctx['item']), key1); + c_block4[i1] = withKey(text(ctx['item']), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -28,20 +34,26 @@ exports[`t-foreach iterate on items (on a element node) 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`\`); + let block3 = createBlock(\`
    + +
    \`); + let block5 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList([1,2]);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`item\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList([1,2]);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`item\`] = v_block4[i1]; const key1 = ctx['item']; let txt1 = ctx['item']; - c_block2[i1] = withKey(block3([txt1]), key1); + c_block4[i1] = withKey(block5([txt1]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -52,27 +64,35 @@ exports[`t-foreach iterate on items 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList([3,2,1]);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`item\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList([3,2,1]);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`item\`] = v_block4[i1]; ctx[\`item_index\`] = i1; - ctx[\`item_value\`] = k_block2[i1]; + ctx[\`item_value\`] = k_block4[i1]; const key1 = ctx['item']; - const b4 = text(\` [\`); - const b5 = text(ctx['item_index']); - const b6 = text(\`: \`); - const b7 = text(ctx['item']); - const b8 = text(\` \`); - const b9 = text(ctx['item_value']); - const b10 = text(\`] \`); - c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9, b10]), key1); + const b6 = text(\` + [\`); + const b7 = text(ctx['item_index']); + const b8 = text(\`: \`); + const b9 = text(ctx['item']); + const b10 = text(\` \`); + const b11 = text(ctx['item_value']); + const b12 = text(\`] + \`); + c_block4[i1] = withKey(multi([b6, b7, b8, b9, b10, b11, b12]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -83,27 +103,35 @@ exports[`t-foreach iterate, dict param 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['value']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`item\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['value']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`item\`] = v_block4[i1]; ctx[\`item_index\`] = i1; - ctx[\`item_value\`] = k_block2[i1]; + ctx[\`item_value\`] = k_block4[i1]; const key1 = ctx['item_index']; - const b4 = text(\` [\`); - const b5 = text(ctx['item_index']); - const b6 = text(\`: \`); - const b7 = text(ctx['item']); - const b8 = text(\` \`); - const b9 = text(ctx['item_value']); - const b10 = text(\`] \`); - c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9, b10]), key1); + const b6 = text(\` + [\`); + const b7 = text(ctx['item_index']); + const b8 = text(\`: \`); + const b9 = text(ctx['item']); + const b10 = text(\` \`); + const b11 = text(ctx['item_value']); + const b12 = text(\`] + \`); + c_block4[i1] = withKey(multi([b6, b7, b8, b9, b10, b11, b12]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -114,32 +142,40 @@ exports[`t-foreach iterate, position 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(Array(5));; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`elem\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(Array(5));; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`elem\`] = v_block4[i1]; ctx[\`elem_first\`] = i1 === 0; - ctx[\`elem_last\`] = i1 === v_block2.length - 1; + ctx[\`elem_last\`] = i1 === v_block4.length - 1; ctx[\`elem_index\`] = i1; const key1 = ctx['elem']; - let b4,b5,b6,b7,b8,b9; - b4 = text(\` -\`); + let b6,b7,b8,b9,b10,b11; + b6 = text(\` + -\`); if (ctx['elem_first']) { - b5 = text(\` first\`); + b7 = text(\` first\`); } if (ctx['elem_last']) { - b6 = text(\` last\`); + b8 = text(\` last\`); } - b7 = text(\` (\`); - b8 = text(ctx['elem_index']); - b9 = text(\`) \`); - c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9]), key1); + b9 = text(\` (\`); + b10 = text(ctx['elem_index']); + b11 = text(\`) + \`); + c_block4[i1] = withKey(multi([b6, b7, b8, b9, b10, b11]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -150,18 +186,24 @@ exports[`t-foreach simple iteration (in a node) 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList([3,2,1]);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`item\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList([3,2,1]);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`item\`] = v_block4[i1]; const key1 = ctx['item']; - c_block2[i1] = withKey(text(ctx['item']), key1); + c_block4[i1] = withKey(text(ctx['item']), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -191,22 +233,31 @@ exports[`t-foreach simple iteration with two nodes inside 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block3 = createBlock(\`a\`); - let block4 = createBlock(\`b\`); + let block6 = createBlock(\`a\`); + let block8 = createBlock(\`b\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block1, v_block1, l_block1, c_block1] = prepareList([3,2,1]);; - for (let i1 = 0; i1 < l_block1; i1++) { - ctx[\`item\`] = v_block1[i1]; + const [k_block3, v_block3, l_block3, c_block3] = prepareList([3,2,1]);; + for (let i1 = 0; i1 < l_block3; i1++) { + ctx[\`item\`] = v_block3[i1]; const key1 = ctx['item']; + const b5 = text(\` + \`); let txt1 = ctx['item']; - const b3 = block3([txt1]); + const b6 = block6([txt1]); + const b7 = text(\` + \`); let txt2 = ctx['item']; - const b4 = block4([txt2]); - c_block1[i1] = withKey(multi([b3, b4]), key1); + const b8 = block8([txt2]); + const b9 = text(\` + \`); + c_block3[i1] = withKey(multi([b5, b6, b7, b8, b9]), key1); } - return list(c_block1); + const b3 = list(c_block3); + return multi([b2, b3]); } }" `; @@ -215,51 +266,74 @@ exports[`t-foreach t-call with body in t-foreach in t-foreach 1`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { prepareList, isBoundary, withDefault, setContextValue, withKey } = helpers; + let { prepareList, isBoundary, withDefault, setContextValue, zero, withKey } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    [][][]
    \`); - let block6 = createBlock(\`\`); + let block3 = createBlock(\`
    + + [][][] +
    \`); + let block16 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['numbers']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`a\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['numbers']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`a\`] = v_block4[i1]; ctx[\`a_first\`] = i1 === 0; - ctx[\`a_last\`] = i1 === v_block2.length - 1; + ctx[\`a_last\`] = i1 === v_block4.length - 1; ctx[\`a_index\`] = i1; - ctx[\`a_value\`] = k_block2[i1]; + ctx[\`a_value\`] = k_block4[i1]; const key1 = ctx['a']; + const b6 = text(\` + \`); ctx = Object.create(ctx); - const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['letters']);; - for (let i2 = 0; i2 < l_block4; i2++) { - ctx[\`b\`] = v_block4[i2]; + const [k_block7, v_block7, l_block7, c_block7] = prepareList(ctx['letters']);; + for (let i2 = 0; i2 < l_block7; i2++) { + ctx[\`b\`] = v_block7[i2]; ctx[\`b_first\`] = i2 === 0; - ctx[\`b_last\`] = i2 === v_block4.length - 1; + ctx[\`b_last\`] = i2 === v_block7.length - 1; ctx[\`b_index\`] = i2; - ctx[\`b_value\`] = k_block4[i2]; + ctx[\`b_value\`] = k_block7[i2]; const key2 = ctx['b']; + const b9 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b11 = text(\` + \`); setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']); - c_block4[i2] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`), key2); + const b12 = text(\` + \`); + const b10 = multi([b11, b12]); + ctx[zero] = b10; + const b13 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`); ctx = ctx.__proto__; + const b14 = text(\` + \`); + c_block7[i2] = withKey(multi([b9, b13, b14]), key2); } ctx = ctx.__proto__; - const b4 = list(c_block4); + const b7 = list(c_block7); + const b15 = text(\` + \`); let txt1 = ctx['c']; - const b6 = block6([txt1]); - c_block2[i1] = withKey(multi([b4, b6]), key1); + const b16 = block16([txt1]); + const b17 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b15, b16, b17]), key1); } ctx = ctx.__proto__; - const b2 = list(c_block2); + const b4 = list(c_block4); let txt2 = ctx['a']; let txt3 = ctx['b']; let txt4 = ctx['c']; - return block1([txt2, txt3, txt4], [b2]); + const b3 = block3([txt2, txt3, txt4], [b4]); + return multi([b2, b3]); } }" `; @@ -270,14 +344,20 @@ exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; return function template(ctx, node, key = \\"\\") { - const b2 = text(\` [\`); - const b3 = text(ctx['a']); - const b4 = text(\`] [\`); - const b5 = text(ctx['b']); - const b6 = text(\`] [\`); - const b7 = text(ctx['c']); - const b8 = text(\`] \`); - return multi([b2, b3, b4, b5, b6, b7, b8]); + const b2 = text(\` + \`); + const b3 = text(\` + [\`); + const b4 = text(ctx['a']); + const b5 = text(\`] + [\`); + const b6 = text(ctx['b']); + const b7 = text(\`] + [\`); + const b8 = text(ctx['c']); + const b9 = text(\`] + \`); + return multi([b2, b3, b4, b5, b6, b7, b8, b9]); } }" `; @@ -289,42 +369,59 @@ exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = ` let { prepareList, withKey } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    [][][]
    \`); - let block6 = createBlock(\`\`); + let block3 = createBlock(\`
    + + [][][] +
    \`); + let block13 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['numbers']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`a\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['numbers']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`a\`] = v_block4[i1]; ctx[\`a_first\`] = i1 === 0; - ctx[\`a_last\`] = i1 === v_block2.length - 1; + ctx[\`a_last\`] = i1 === v_block4.length - 1; ctx[\`a_index\`] = i1; - ctx[\`a_value\`] = k_block2[i1]; + ctx[\`a_value\`] = k_block4[i1]; const key1 = ctx['a']; + const b6 = text(\` + \`); ctx = Object.create(ctx); - const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['letters']);; - for (let i2 = 0; i2 < l_block4; i2++) { - ctx[\`b\`] = v_block4[i2]; + const [k_block7, v_block7, l_block7, c_block7] = prepareList(ctx['letters']);; + for (let i2 = 0; i2 < l_block7; i2++) { + ctx[\`b\`] = v_block7[i2]; ctx[\`b_first\`] = i2 === 0; - ctx[\`b_last\`] = i2 === v_block4.length - 1; + ctx[\`b_last\`] = i2 === v_block7.length - 1; ctx[\`b_index\`] = i2; - ctx[\`b_value\`] = k_block4[i2]; + ctx[\`b_value\`] = k_block7[i2]; const key2 = ctx['b']; - c_block4[i2] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`), key2); + const b9 = text(\` + \`); + const b10 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`); + const b11 = text(\` + \`); + c_block7[i2] = withKey(multi([b9, b10, b11]), key2); } ctx = ctx.__proto__; - const b4 = list(c_block4); + const b7 = list(c_block7); + const b12 = text(\` + \`); let txt1 = ctx['c']; - const b6 = block6([txt1]); - c_block2[i1] = withKey(multi([b4, b6]), key1); + const b13 = block13([txt1]); + const b14 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b12, b13, b14]), key1); } ctx = ctx.__proto__; - const b2 = list(c_block2); + const b4 = list(c_block4); let txt2 = ctx['a']; let txt3 = ctx['b']; let txt4 = ctx['c']; - return block1([txt2, txt3, txt4], [b2]); + const b3 = block3([txt2, txt3, txt4], [b4]); + return multi([b2, b3]); } }" `; @@ -338,15 +435,23 @@ exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = ` return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); + const b3 = text(\` + \`); setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']); - const b2 = text(\` [\`); - const b3 = text(ctx['a']); - const b4 = text(\`] [\`); - const b5 = text(ctx['b']); - const b6 = text(\`] [\`); - const b7 = text(ctx['c']); - const b8 = text(\`] \`); - return multi([b2, b3, b4, b5, b6, b7, b8]); + const b4 = text(\` + [\`); + const b5 = text(ctx['a']); + const b6 = text(\`] + [\`); + const b7 = text(ctx['b']); + const b8 = text(\`] + [\`); + const b9 = text(ctx['c']); + const b10 = text(\`] + \`); + return multi([b2, b3, b4, b5, b6, b7, b8, b9, b10]); } }" `; @@ -357,30 +462,43 @@ exports[`t-foreach t-foreach in t-foreach 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['numbers']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`number\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['numbers']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`number\`] = v_block4[i1]; const key1 = ctx['number']; + const b6 = text(\` + \`); ctx = Object.create(ctx); - const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['letters']);; - for (let i2 = 0; i2 < l_block3; i2++) { - ctx[\`letter\`] = v_block3[i2]; + const [k_block7, v_block7, l_block7, c_block7] = prepareList(ctx['letters']);; + for (let i2 = 0; i2 < l_block7; i2++) { + ctx[\`letter\`] = v_block7[i2]; const key2 = ctx['letter']; - const b5 = text(\` [\`); - const b6 = text(ctx['number']); - const b7 = text(ctx['letter']); - const b8 = text(\`] \`); - c_block3[i2] = withKey(multi([b5, b6, b7, b8]), key2); + const b9 = text(\` + [\`); + const b10 = text(ctx['number']); + const b11 = text(ctx['letter']); + const b12 = text(\`] + \`); + c_block7[i2] = withKey(multi([b9, b10, b11, b12]), key2); } ctx = ctx.__proto__; - c_block2[i1] = withKey(list(c_block3), key1); + const b7 = list(c_block7); + const b13 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b13]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -391,22 +509,29 @@ exports[`t-foreach t-foreach with t-if inside (no external node) 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block3 = createBlock(\`\`); + let block6 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['elems']);; - for (let i1 = 0; i1 < l_block1; i1++) { - ctx[\`elem\`] = v_block1[i1]; + const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['elems']);; + for (let i1 = 0; i1 < l_block3; i1++) { + ctx[\`elem\`] = v_block3[i1]; const key1 = ctx['elem'].id; - let b3; + let b5,b6,b7; + b5 = text(\` + \`); if (ctx['elem'].id<3) { let txt1 = ctx['elem'].text; - b3 = block3([txt1]); + b6 = block6([txt1]); } - c_block1[i1] = withKey(multi([b3]), key1); + b7 = text(\` + \`); + c_block3[i1] = withKey(multi([b5, b6, b7]), key1); } - return list(c_block1); + const b3 = list(c_block3); + return multi([b2, b3]); } }" `; @@ -417,24 +542,34 @@ exports[`t-foreach t-foreach with t-if inside 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); - let block4 = createBlock(\`\`); + let block3 = createBlock(\`
    + +
    \`); + let block7 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['elems']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`elem\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['elems']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`elem\`] = v_block4[i1]; const key1 = ctx['elem'].id; - let b4; + let b6,b7,b8; + b6 = text(\` + \`); if (ctx['elem'].id<3) { let txt1 = ctx['elem'].text; - b4 = block4([txt1]); + b7 = block7([txt1]); } - c_block2[i1] = withKey(multi([b4]), key1); + b8 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b8]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -445,19 +580,30 @@ exports[`t-foreach t-key on t-foreach 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`\`); + let block3 = createBlock(\`
    + +
    \`); + let block7 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['things']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`thing\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['things']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`thing\`] = v_block4[i1]; const key1 = ctx['thing']; - c_block2[i1] = withKey(block3(), key1); + const b6 = text(\` + \`); + const b7 = block7(); + const b8 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b8]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -493,33 +639,42 @@ exports[`t-foreach with t-memo 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`

    \`); + let block3 = createBlock(\`
    + +
    \`); + let block5 = createBlock(\`

    + + +

    \`); return function template(ctx, node, key = \\"\\") { let cache = ctx.cache || {}; let nextCache = ctx.cache = {}; + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['items']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`item\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['items']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`item\`] = v_block4[i1]; const key1 = ctx['item'].id; const memo1 = [ctx['item'].x]; const vnode1 = cache[key1];; if (vnode1) { if (shallowEqual(vnode1.memo, memo1)) { - c_block2[i1] = vnode1; + c_block4[i1] = vnode1; nextCache[key1] = vnode1; continue; } } let txt1 = ctx['item'].x; let txt2 = ctx['item'].y; - c_block2[i1] = withKey(block3([txt1, txt2]), key1); - nextCache[key1] = Object.assign(c_block2[i1], {memo: memo1}); + c_block4[i1] = withKey(block5([txt1, txt2]), key1); + nextCache[key1] = Object.assign(c_block4[i1], {memo: memo1}); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; diff --git a/tests/compiler/__snapshots__/t_if.test.ts.snap b/tests/compiler/__snapshots__/t_if.test.ts.snap index 4f3f6be2..a1f3dd33 100644 --- a/tests/compiler/__snapshots__/t_if.test.ts.snap +++ b/tests/compiler/__snapshots__/t_if.test.ts.snap @@ -44,17 +44,19 @@ 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,b6; + b2 = text(\` + \`); if (ctx['color']=='black') { - b2 = text(\`black pearl\`); + b3 = text(\`black pearl\`); } else if (ctx['color']=='yellow') { - b3 = text(\`yellow submarine\`); + b4 = text(\`yellow submarine\`); } else if (ctx['color']=='red') { - b4 = text(\`red is dead\`); + b5 = text(\`red is dead\`); } else { - b5 = text(\`beer\`); + b6 = text(\`beer\`); } - return multi([b2, b3, b4, b5]); + return multi([b2, b3, b4, b5, b6]); } }" `; @@ -64,20 +66,25 @@ exports[`t-if boolean value condition elif 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3,b4,b5; + const b2 = text(\` + \`); + let b4,b5,b6,b7; if (ctx['color']=='black') { - b2 = text(\`black pearl\`); + b4 = text(\`black pearl\`); } else if (ctx['color']=='yellow') { - b3 = text(\`yellow submarine\`); + b5 = text(\`yellow submarine\`); } else if (ctx['color']=='red') { - b4 = text(\`red is dead\`); + b6 = text(\`red is dead\`); } else { - b5 = text(\`beer\`); + b7 = text(\`beer\`); } - return block1([], [b2, b3, b4, b5]); + const b3 = block3([], [b4, b5, b6, b7]); + return multi([b2, b3]); } }" `; @@ -87,16 +94,23 @@ exports[`t-if boolean value condition else 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    beginend
    \`); + let block3 = createBlock(\`
    + begin + + end +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['condition']) { - b2 = text(\`ok\`); + b4 = text(\`ok\`); } else { - b3 = text(\`ok-else\`); + b5 = text(\`ok-else\`); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -106,16 +120,19 @@ exports[`t-if boolean value condition false else 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    beginend
    \`); + let block3 = createBlock(\`
    beginend
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['condition']) { - b2 = text(\`fail\`); + b4 = text(\`fail\`); } else { - b3 = text(\`fail-else\`); + b5 = text(\`fail-else\`); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -142,35 +159,47 @@ exports[`t-if can use some boolean operators in expressions 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + + + + + + + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3,b4,b5,b6,b7,b8,b9; + const b2 = text(\` + \`); + let b4,b5,b6,b7,b8,b9,b10,b11; if (ctx['cond1']&&ctx['cond2']) { - b2 = text(\`and\`); + b4 = text(\`and\`); } if (ctx['cond1']&&ctx['cond3']) { - b3 = text(\`nope\`); - } - if (ctx['cond1']||ctx['cond3']) { - b4 = text(\`or\`); - } - if (ctx['cond3']||ctx['cond4']) { b5 = text(\`nope\`); } + if (ctx['cond1']||ctx['cond3']) { + b6 = text(\`or\`); + } + if (ctx['cond3']||ctx['cond4']) { + b7 = text(\`nope\`); + } if (ctx['m']>3) { - b6 = text(\`mgt\`); + b8 = text(\`mgt\`); } if (ctx['n']>3) { - b7 = text(\`ngt\`); + b9 = text(\`ngt\`); } if (ctx['m']<3) { - b8 = text(\`mlt\`); + b10 = text(\`mlt\`); } if (ctx['n']<3) { - b9 = text(\`nlt\`); + b11 = text(\`nlt\`); } - return block1([], [b2, b3, b4, b5, b6, b7, b8, b9]); + const b3 = block3([], [b4, b5, b6, b7, b8, b9, b10, b11]); + return multi([b2, b3]); } }" `; @@ -407,17 +436,23 @@ exports[`t-if t-set, then t-if 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - let b2; + const b2 = text(\` + \`); + let b4; setContextValue(ctx, \\"title\\", 'test'); if (ctx['title']) { - b2 = text(ctx['title']); + b4 = text(ctx['title']); } - return block1([], [b2]); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -428,19 +463,26 @@ exports[`t-if t-set, then t-if, part 2 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`COUCOU\`); + let block3 = createBlock(\`
    + + + +
    \`); + let block4 = createBlock(\`COUCOU\`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - let b2; + const b2 = text(\` + \`); + let b4; setContextValue(ctx, \\"y\\", true); setContextValue(ctx, \\"x\\", ctx['y']); if (ctx['x']) { - b2 = block2(); + b4 = block4(); } - return block1([], [b2]); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -451,22 +493,29 @@ exports[`t-if t-set, then t-if, part 3 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`AAA\`); - let block3 = createBlock(\`BBB\`); + let block3 = createBlock(\`
    + + + +
    \`); + let block4 = createBlock(\`AAA\`); + let block5 = createBlock(\`BBB\`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; setContextValue(ctx, \\"y\\", false); setContextValue(ctx, \\"x\\", ctx['y']); if (ctx['x']) { - b2 = block2(); + b4 = block4(); } else if (!ctx['x']) { - b3 = block3(); + b5 = block5(); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; diff --git a/tests/compiler/__snapshots__/t_key.test.ts.snap b/tests/compiler/__snapshots__/t_key.test.ts.snap index bac2b2f1..1753df02 100644 --- a/tests/compiler/__snapshots__/t_key.test.ts.snap +++ b/tests/compiler/__snapshots__/t_key.test.ts.snap @@ -51,7 +51,9 @@ exports[`t-key t-key directive in a list 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
      + +
    \`); let block3 = createBlock(\`
  • \`); return function template(ctx, node, key = \\"\\") { @@ -63,6 +65,7 @@ exports[`t-key t-key directive in a list 1`] = ` let txt1 = ctx['beer'].name; c_block2[i1] = withKey(block3([txt1]), key1); } + ctx = ctx.__proto__; const b2 = list(c_block2); return block1([], [b2]); } @@ -74,18 +77,26 @@ exports[`t-key t-key on sub dom node pushes a child block in its parent 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`\`); - let block3 = createBlock(\`

    \`); + let block3 = createBlock(\`
    + + +
    \`); + let block4 = createBlock(\`\`); + let block5 = createBlock(\`

    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['hasSpan']) { - b2 = block2(); + b4 = block4(); } const tKey_1 = ctx['key']; - b3 = toggler(tKey_1, block3()); - return block1([], [b2, b3]); + b5 = toggler(tKey_1, block5()); + const b3 = block3([], [b4, b5]); + const b6 = text(\` + \`); + return multi([b2, b3, b6]); } }" `; diff --git a/tests/compiler/__snapshots__/t_out.test.ts.snap b/tests/compiler/__snapshots__/t_out.test.ts.snap index 097889fb..c1f3fa85 100644 --- a/tests/compiler/__snapshots__/t_out.test.ts.snap +++ b/tests/compiler/__snapshots__/t_out.test.ts.snap @@ -34,16 +34,27 @@ exports[`t-out multiple calls to t-out 1`] = ` let { isBoundary, zero } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`coucou\`); + let block3 = createBlock(\`
    + +
    \`); + let block6 = createBlock(\`coucou\`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); ctx[isBoundary] = 1; - const b2 = block2(); - ctx[zero] = b2; - const b3 = callTemplate_1.call(this, ctx, node, key + \`__1\`); - return block1([], [b3]); + const b5 = text(\` + \`); + const b6 = block6(); + const b7 = text(\` + \`); + const b4 = multi([b5, b6, b7]); + ctx[zero] = b4; + const b8 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + ctx = ctx.__proto__; + const b3 = block3([], [b8]); + return multi([b2, b3]); } }" `; @@ -54,12 +65,19 @@ exports[`t-out multiple calls to t-out 2`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { zero } = helpers; - let block1 = createBlock(\`
    Greeter
    \`); + let block3 = createBlock(\`
    + +
    Greeter
    + +
    \`); return function template(ctx, node, key = \\"\\") { - const b2 = ctx[zero]; - const b3 = ctx[zero]; - return block1([], [b2, b3]); + const b2 = text(\` + \`); + const b4 = ctx[zero]; + const b5 = ctx[zero]; + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -297,10 +315,13 @@ exports[`t-out t-out switch markup on bdom 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, LazyValue, safeOutput } = helpers; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + + +
    \`); let block2 = createBlock(\`
      set
    \`); - let block3 = createBlock(\`\`); let block5 = createBlock(\`\`); + let block10 = createBlock(\`\`); function value1(ctx, node, key = \\"\\") { return block2(); @@ -309,16 +330,26 @@ 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,b8; ctx[\`bdom\`] = new LazyValue(value1, ctx, this, node); if (ctx['hasBdom']) { - const b4 = safeOutput(ctx['bdom']); - b3 = block3([], [b4]); + const b4 = text(\` + \`); + const b6 = safeOutput(ctx['bdom']); + const b5 = block5([], [b6]); + const b7 = text(\` + \`); + b3 = multi([b4, b5, b7]); } else { - const b6 = safeOutput(ctx['var']); - b5 = block5([], [b6]); + const b9 = text(\` + \`); + const b11 = safeOutput(ctx['var']); + const b10 = block10([], [b11]); + const b12 = text(\` + \`); + b8 = multi([b9, b10, b12]); } - return block1([], [b3, b5]); + return block1([], [b3, b8]); } }" `; diff --git a/tests/compiler/__snapshots__/t_ref.test.ts.snap b/tests/compiler/__snapshots__/t_ref.test.ts.snap index 6ee65018..c49eab4b 100644 --- a/tests/compiler/__snapshots__/t_ref.test.ts.snap +++ b/tests/compiler/__snapshots__/t_ref.test.ts.snap @@ -82,17 +82,27 @@ exports[`t-ref ref in a t-if 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`\`); + let block3 = createBlock(\`
    + +
    \`); + let block6 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { const refs = ctx.__owl__.refs; const ref1 = (el) => refs[\`name\`] = el; - let b2; + const b2 = text(\` + \`); + let b4; if (ctx['condition']) { - b2 = block2([ref1]); + const b5 = text(\` + \`); + const b6 = block6([ref1]); + const b7 = text(\` + \`); + b4 = multi([b5, b6, b7]); } - return block1([], [b2]); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -103,8 +113,10 @@ exports[`t-ref refs in a loop 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); + let block5 = createBlock(\`
    \`); return function template(ctx, node, key = \\"\\") { const refs = ctx.__owl__.refs; @@ -113,12 +125,18 @@ exports[`t-ref refs in a loop 1`] = ` for (let i1 = 0; i1 < l_block2; i1++) { ctx[\`item\`] = v_block2[i1]; const key1 = ctx['item']; + const b4 = text(\` + \`); const tKey_1 = ctx['item']; const v1 = ctx['item']; let ref1 = (el) => refs[(v1)] = el; let txt1 = ctx['item']; - c_block2[i1] = withKey(block3([ref1, txt1]), tKey_1 + key1); + const b5 = toggler(tKey_1, block5([ref1, txt1])); + const b6 = text(\` + \`); + c_block2[i1] = withKey(multi([b4, b5, b6]), key1); } + ctx = ctx.__proto__; const b2 = list(c_block2); return block1([], [b2]); } @@ -130,18 +148,29 @@ exports[`t-ref two refs, one in a t-if 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`

    \`); - let block2 = createBlock(\`\`); + let block3 = createBlock(\`
    + +

    +

    \`); + let block6 = createBlock(\`\`); return function template(ctx, node, key = \\"\\") { const refs = ctx.__owl__.refs; const ref1 = (el) => refs[\`name\`] = el; const ref2 = (el) => refs[\`p\`] = el; - let b2; + const b2 = text(\` + \`); + let b4; if (ctx['condition']) { - b2 = block2([ref1]); + const b5 = text(\` + \`); + const b6 = block6([ref1]); + const b7 = text(\` + \`); + b4 = multi([b5, b6, b7]); } - return block1([ref2], [b2]); + const b3 = block3([ref2], [b4]); + return multi([b2, b3]); } }" `; diff --git a/tests/compiler/__snapshots__/t_set.test.ts.snap b/tests/compiler/__snapshots__/t_set.test.ts.snap index ed9b08e3..737922f5 100644 --- a/tests/compiler/__snapshots__/t_set.test.ts.snap +++ b/tests/compiler/__snapshots__/t_set.test.ts.snap @@ -94,20 +94,33 @@ 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 b5,b6,b7,b8; + b5 = text(\` + \`); if (ctx['condition']) { - b2 = text(\`true\`); + b6 = text(\`true\`); } else { - b3 = text(\`false\`); + b7 = text(\`false\`); } - return multi([b2, b3]); + b8 = text(\` + \`); + return multi([b5, b6, b7, b8]); } return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); + const b3 = text(\` + \`); ctx[\`value\`] = new LazyValue(value1, ctx, this, node); - return text(ctx['value']); + const b9 = text(\` + \`); + const b10 = text(ctx['value']); + const b11 = text(\` + \`); + return multi([b2, b3, b9, b10, b11]); } }" `; @@ -173,17 +186,23 @@ exports[`t-set t-set and t-if 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - let b2; + const b2 = text(\` + \`); + let b4; setContextValue(ctx, \\"v\\", ctx['value']); if (ctx['v']==='ok') { - b2 = text(\`grimbergen\`); + b4 = text(\`grimbergen\`); } - return block1([], [b2]); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -194,22 +213,35 @@ exports[`t-set t-set body is evaluated immediately 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`\`); + let block3 = createBlock(\`
    + + + + +
    \`); + let block6 = createBlock(\`\`); function value1(ctx, node, key = \\"\\") { + const b5 = text(\` + \`); let txt1 = ctx['v1']; - return block2([txt1]); + const b6 = block6([txt1]); + const b7 = text(\` + \`); + return multi([b5, b6, b7]); } return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"v1\\", 'before'); ctx[\`v2\`] = new LazyValue(value1, ctx, this, node); setContextValue(ctx, \\"v1\\", 'after'); - const b3 = safeOutput(ctx['v2']); - return block1([], [b3]); + const b8 = safeOutput(ctx['v2']); + const b3 = block3([], [b8]); + return multi([b2, b3]); } }" `; @@ -221,16 +253,26 @@ exports[`t-set t-set can't alter from within callee 1`] = ` let { isBoundary, withDefault, setContextValue } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`

    \`); + let block3 = createBlock(\`
    + +

    + +

    +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"iter\\", 'source'); let txt1 = ctx['iter']; - const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b4 = callTemplate_1.call(this, ctx, node, key + \`__1\`); let txt2 = ctx['iter']; - return block1([txt1, txt2], [b2]); + const b3 = block3([txt1, txt2], [b4]); + const b5 = text(\` + \`); + return multi([b2, b3, b5]); } }" `; @@ -258,23 +300,39 @@ exports[`t-set t-set can't alter in t-call body 1`] = ` "function anonymous(app, bdom, helpers ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let { isBoundary, withDefault, setContextValue } = helpers; + let { isBoundary, withDefault, setContextValue, zero } = helpers; const callTemplate_1 = app.getTemplate(\`sub\`); - let block1 = createBlock(\`

    \`); + let block3 = createBlock(\`
    + +

    + +

    +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"iter\\", 'source'); let txt1 = ctx['iter']; ctx = Object.create(ctx); ctx[isBoundary] = 1; + const b5 = text(\` + \`); setContextValue(ctx, \\"iter\\", 'inCall'); - const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`); + const b6 = text(\` + \`); + const b4 = multi([b5, b6]); + ctx[zero] = b4; + const b7 = callTemplate_1.call(this, ctx, node, key + \`__1\`); ctx = ctx.__proto__; let txt2 = ctx['iter']; - return block1([txt1, txt2], [b2]); + const b3 = block3([txt1, txt2], [b7]); + const b8 = text(\` + \`); + return multi([b2, b3, b8]); } }" `; @@ -322,15 +380,22 @@ exports[`t-set t-set evaluates an expression only once 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"v\\", ctx['value']+' artois'); let txt1 = ctx['v']; let txt2 = ctx['v']; - return block1([txt1, txt2]); + const b3 = block3([txt1, txt2]); + return multi([b2, b3]); } }" `; @@ -341,26 +406,42 @@ exports[`t-set t-set outside modified in t-foreach 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; - let block1 = createBlock(\`

    EndLoop:

    \`); - let block3 = createBlock(\`

    InLoop:

    \`); + let block3 = createBlock(\`
    + + +

    EndLoop:

    +
    \`); + let block7 = createBlock(\`

    InLoop:

    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"iter\\", 0); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`val\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(['a','b']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`val\`] = v_block4[i1]; const key1 = ctx['val']; + const b6 = text(\` + \`); let txt1 = ctx['iter']; - c_block2[i1] = withKey(block3([txt1]), key1); + const b7 = block7([txt1]); + const b8 = text(\` + \`); setContextValue(ctx, \\"iter\\", ctx['iter']+1); + const b9 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b8, b9]), key1); } ctx = ctx.__proto__; - const b2 = list(c_block2); + const b4 = list(c_block4); let txt2 = ctx['iter']; - return block1([txt2], [b2]); + const b3 = block3([txt2], [b4]); + const b10 = text(\` + \`); + return multi([b2, b3, b10]); } }" `; @@ -371,26 +452,42 @@ exports[`t-set t-set outside modified in t-foreach increment-after operator 1`] let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; - let block1 = createBlock(\`

    EndLoop:

    \`); - let block3 = createBlock(\`

    InLoop:

    \`); + let block3 = createBlock(\`
    + + +

    EndLoop:

    +
    \`); + let block7 = createBlock(\`

    InLoop:

    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"iter\\", 0); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`val\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(['a','b']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`val\`] = v_block4[i1]; const key1 = ctx['val']; + const b6 = text(\` + \`); let txt1 = ctx['iter']; - c_block2[i1] = withKey(block3([txt1]), key1); + const b7 = block7([txt1]); + const b8 = text(\` + \`); setContextValue(ctx, \\"iter\\", ctx['iter']++); + const b9 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b8, b9]), key1); } ctx = ctx.__proto__; - const b2 = list(c_block2); + const b4 = list(c_block4); let txt2 = ctx['iter']; - return block1([txt2], [b2]); + const b3 = block3([txt2], [b4]); + const b10 = text(\` + \`); + return multi([b2, b3, b10]); } }" `; @@ -401,26 +498,42 @@ exports[`t-set t-set outside modified in t-foreach increment-before operator 1`] let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; - let block1 = createBlock(\`

    EndLoop:

    \`); - let block3 = createBlock(\`

    InLoop:

    \`); + let block3 = createBlock(\`
    + + +

    EndLoop:

    +
    \`); + let block7 = createBlock(\`

    InLoop:

    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"iter\\", 0); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(['a','b']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`val\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(['a','b']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`val\`] = v_block4[i1]; const key1 = ctx['val']; + const b6 = text(\` + \`); let txt1 = ctx['iter']; - c_block2[i1] = withKey(block3([txt1]), key1); + const b7 = block7([txt1]); + const b8 = text(\` + \`); setContextValue(ctx, \\"iter\\", ++ctx['iter']); + const b9 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b8, b9]), key1); } ctx = ctx.__proto__; - const b2 = list(c_block2); + const b4 = list(c_block4); let txt2 = ctx['iter']; - return block1([txt2], [b2]); + const b3 = block3([txt2], [b4]); + const b10 = text(\` + \`); + return multi([b2, b3, b10]); } }" `; @@ -431,25 +544,35 @@ exports[`t-set t-set should reuse variable if possible 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers; - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`
    v
    \`); + let block3 = createBlock(\`
    + + +
    \`); + let block5 = createBlock(\`
    + v + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"v\\", 1); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['list']);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`elem\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['list']);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`elem\`] = v_block4[i1]; ctx[\`elem_index\`] = i1; const key1 = ctx['elem_index']; let txt1 = ctx['v']; setContextValue(ctx, \\"v\\", ctx['elem']); - c_block2[i1] = withKey(block3([txt1]), key1); + c_block4[i1] = withKey(block5([txt1]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -460,20 +583,26 @@ exports[`t-set t-set with content and sub t-esc 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, LazyValue } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); function value1(ctx, node, key = \\"\\") { - const b3 = text(ctx['beep']); - const b4 = text(\` boop\`); - return multi([b3, b4]); + const b5 = text(ctx['beep']); + const b6 = text(\` boop\`); + return multi([b5, b6]); } return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); ctx[\`setvar\`] = new LazyValue(value1, ctx, this, node); let txt1 = ctx['setvar']; - return block1([txt1]); + const b3 = block3([txt1]); + return multi([b2, b3]); } }" `; @@ -484,24 +613,39 @@ exports[`t-set t-set with t-value (falsy) and body 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`\`); + let block3 = createBlock(\`
    + + + + + + +
    \`); + let block6 = createBlock(\`\`); function value1(ctx, node, key = \\"\\") { + const b5 = text(\` + \`); let txt1 = ctx['v1']; - return block2([txt1]); + const b6 = block6([txt1]); + const b7 = text(\` + \`); + return multi([b5, b6, b7]); } return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"v3\\", false); setContextValue(ctx, \\"v1\\", 'before'); ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, this, node)); setContextValue(ctx, \\"v1\\", 'after'); setContextValue(ctx, \\"v3\\", true); - const b3 = safeOutput(ctx['v2']); - return block1([], [b3]); + const b8 = safeOutput(ctx['v2']); + const b3 = block3([], [b8]); + return multi([b2, b3]); } }" `; @@ -512,24 +656,39 @@ exports[`t-set t-set with t-value (truthy) and body 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers; - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`\`); + let block3 = createBlock(\`
    + + + + + + +
    \`); + let block6 = createBlock(\`\`); function value1(ctx, node, key = \\"\\") { + const b5 = text(\` + \`); let txt1 = ctx['v1']; - return block2([txt1]); + const b6 = block6([txt1]); + const b7 = text(\` + \`); + return multi([b5, b6, b7]); } return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); setContextValue(ctx, \\"v3\\", 'Truthy'); setContextValue(ctx, \\"v1\\", 'before'); ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, this, node)); setContextValue(ctx, \\"v1\\", 'after'); setContextValue(ctx, \\"v3\\", false); - const b3 = safeOutput(ctx['v2']); - return block1([], [b3]); + const b8 = safeOutput(ctx['v2']); + const b3 = block3([], [b8]); + return multi([b2, b3]); } }" `; @@ -540,19 +699,30 @@ exports[`t-set t-set, multiple t-ifs, and a specific configuration 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`

    First div

    \`); + let block3 = createBlock(\`

    +

    + + First div +
    +
    + +
    +

    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - let b2; + const b2 = text(\` + \`); + let b4; if (ctx['flag']) { setContextValue(ctx, \\"bouh\\", 2); } if (!ctx['flag']) { - b2 = text(\`Second\`); + b4 = text(\`Second\`); } - return block1([], [b2]); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -563,18 +733,24 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 1 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); if (ctx['flag']) { setContextValue(ctx, \\"ourvar\\", \`1\`); } else { setContextValue(ctx, \\"ourvar\\", 0); } let txt1 = ctx['ourvar']; - return block1([txt1]); + const b3 = block3([txt1]); + return multi([b2, b3]); } }" `; @@ -585,18 +761,24 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 2 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { isBoundary, withDefault, setContextValue } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 + const b2 = text(\` + \`); if (ctx['flag']) { setContextValue(ctx, \\"ourvar\\", 1); } else { setContextValue(ctx, \\"ourvar\\", \`0\`); } let txt1 = ctx['ourvar']; - return block1([txt1]); + const b3 = block3([txt1]); + return multi([b2, b3]); } }" `; @@ -610,14 +792,18 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 3 1`] = ` return function template(ctx, node, key = \\"\\") { ctx = Object.create(ctx); ctx[isBoundary] = 1 - let b2; + let b2,b3,b4; + b2 = text(\` + \`); if (ctx['flag']) { setContextValue(ctx, \\"ourvar\\", 1); } else { setContextValue(ctx, \\"ourvar\\", \`0\`); } - b2 = text(ctx['ourvar']); - return multi([b2]); + b3 = text(\` + \`); + b4 = text(ctx['ourvar']); + return multi([b2, b3, b4]); } }" `; diff --git a/tests/compiler/__snapshots__/t_tag.test.ts.snap b/tests/compiler/__snapshots__/t_tag.test.ts.snap index 9c2e8b8f..a8ba2312 100644 --- a/tests/compiler/__snapshots__/t_tag.test.ts.snap +++ b/tests/compiler/__snapshots__/t_tag.test.ts.snap @@ -75,11 +75,18 @@ exports[`qweb t-tag with multiple child nodes 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = tag => createBlock(\`<\${tag || 't'}> pear apple strawberry \`); + let block3 = tag => createBlock(\`<\${tag || 't'}> + pear + apple + strawberry + \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); const tag1 = ctx['tag']; - return toggler(tag1, block1(tag1)()); + const b3 = toggler(tag1, block3(tag1)()); + return multi([b2, b3]); } }" `; diff --git a/tests/compiler/__snapshots__/translation.test.ts.snap b/tests/compiler/__snapshots__/translation.test.ts.snap index 877a307b..8dc9f691 100644 --- a/tests/compiler/__snapshots__/translation.test.ts.snap +++ b/tests/compiler/__snapshots__/translation.test.ts.snap @@ -5,10 +5,15 @@ exports[`translation support can set and remove translatable attributes 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    text
    \`); + let block3 = createBlock(\`
    text
    \`); return function template(ctx, node, key = \\"\\") { - return block1(); + const b2 = text(\` + \`); + const b3 = block3(); + const b4 = text(\` + \`); + return multi([b2, b3, b4]); } }" `; @@ -31,10 +36,18 @@ exports[`translation support does not translate node content if disabled 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    motword
    \`); + let block3 = createBlock(\`
    + mot + word +
    \`); return function template(ctx, node, key = \\"\\") { - return block1(); + const b2 = text(\` + \`); + const b3 = block3(); + const b4 = text(\` + \`); + return multi([b2, b3, b4]); } }" `; @@ -44,10 +57,21 @@ exports[`translation support some attributes are translated 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`

    mot

    mot

    mot

    mot

    mot

    \`); + let block3 = createBlock(\`
    +

    mot

    +

    mot

    +

    mot

    +

    mot

    +

    mot

    +
    \`); return function template(ctx, node, key = \\"\\") { - return block1(); + const b2 = text(\` + \`); + const b3 = block3(); + const b4 = text(\` + \`); + return multi([b2, b3, b4]); } }" `; @@ -57,10 +81,15 @@ exports[`translation support translation is done on the trimmed text, with extra ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    mot
    \`); + let block3 = createBlock(\`
    mot
    \`); return function template(ctx, node, key = \\"\\") { - return block1(); + const b2 = text(\` + \`); + const b3 = block3(); + const b4 = text(\` + \`); + return multi([b2, b3, b4]); } }" `; diff --git a/tests/compiler/__snapshots__/white_space.test.ts.snap b/tests/compiler/__snapshots__/white_space.test.ts.snap index 4e65964b..71d367fa 100644 --- a/tests/compiler/__snapshots__/white_space.test.ts.snap +++ b/tests/compiler/__snapshots__/white_space.test.ts.snap @@ -61,7 +61,8 @@ exports[`white space handling pre inside a div with a new line 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    SomeText
    \`); + let block1 = createBlock(\`
    SomeText
    +
    \`); return function template(ctx, node, key = \\"\\") { return block1(); @@ -87,7 +88,9 @@ exports[`white space handling whitespace only text nodes with newlines are remov ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    abc
    \`); + let block1 = createBlock(\`
    + abc +
    \`); return function template(ctx, node, key = \\"\\") { return block1(); diff --git a/tests/components/__snapshots__/basics.test.ts.snap b/tests/components/__snapshots__/basics.test.ts.snap index 2a75d381..68ff29a2 100644 --- a/tests/components/__snapshots__/basics.test.ts.snap +++ b/tests/components/__snapshots__/basics.test.ts.snap @@ -130,13 +130,16 @@ exports[`basics can be clicked on and updated 1`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['state'].counter; const v1 = ctx['state']; let hdlr1 = [()=>v1.counter++, ctx]; - return block1([txt1, hdlr1]); + const b3 = block3([txt1, hdlr1]); + return multi([b2, b3]); } }" `; @@ -485,21 +488,30 @@ exports[`basics list of two sub components inside other nodes 1`] = ` const comp1 = app.createComponent(\`SubWidget\`, true, false, false, true); const comp2 = app.createComponent(\`SubWidget\`, true, false, false, true); - let block1 = createBlock(\`
    \`); - let block3 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); + let block5 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].blips);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`blip\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].blips);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`blip\`] = v_block4[i1]; const key1 = ctx['blip'].id; - const b4 = comp1({}, key + \`__1__\${key1}\`, node, this, null); - const b5 = comp2({}, key + \`__2__\${key1}\`, node, this, null); - c_block2[i1] = withKey(block3([], [b4, b5]), key1); + const b6 = comp1({}, key + \`__1__\${key1}\`, node, this, null); + const b7 = comp2({}, key + \`__2__\${key1}\`, node, this, null); + c_block4[i1] = withKey(block5([], [b6, b7]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -600,13 +612,21 @@ exports[`basics reconciliation alg is not confused in some specific situation 1` const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp2 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { - const b2 = comp1({}, key + \`__1\`, node, this, null); + const b2 = text(\` + \`); + const b4 = comp1({}, key + \`__1\`, node, this, null); const tKey_1 = 4; - const b3 = toggler(tKey_1, comp2({}, tKey_1 + key + \`__2\`, node, this, null)); - return block1([], [b2, b3]); + const b5 = toggler(tKey_1, comp2({}, tKey_1 + key + \`__2\`, node, this, null)); + const b3 = block3([], [b4, b5]); + const b6 = text(\` + \`); + return multi([b2, b3, b6]); } }" `; @@ -641,13 +661,16 @@ exports[`basics rerendering a widget with a sub widget 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['state'].counter; const v1 = ctx['state']; let hdlr1 = [()=>v1.counter++, ctx]; - return block1([txt1, hdlr1]); + const b3 = block3([txt1, hdlr1]); + return multi([b2, b3]); } }" `; @@ -659,14 +682,20 @@ exports[`basics same t-keys in two different places 1`] = ` const comp1 = app.createComponent(\`Child\`, true, false, false, false); const comp2 = app.createComponent(\`Child\`, true, false, false, false); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    +
    +
    +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); const tKey_1 = 1; - const b2 = toggler(tKey_1, comp1({blip: '1'}, tKey_1 + key + \`__1\`, node, this, null)); + const b4 = toggler(tKey_1, comp1({blip: '1'}, tKey_1 + key + \`__1\`, node, this, null)); const tKey_2 = 1; - const b3 = toggler(tKey_2, comp2({blip: '2'}, tKey_2 + key + \`__2\`, node, this, null)); - return block1([], [b2, b3]); + const b5 = toggler(tKey_2, comp2({blip: '2'}, tKey_2 + key + \`__2\`, node, this, null)); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -732,23 +761,30 @@ exports[`basics sub components between t-ifs 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`

    hey

    \`); - let block3 = createBlock(\`

    noo

    \`); - let block5 = createBlock(\`test\`); + let block3 = createBlock(\`
    + + + +
    \`); + let block4 = createBlock(\`

    hey

    \`); + let block5 = createBlock(\`

    noo

    \`); + let block7 = createBlock(\`test\`); return function template(ctx, node, key = \\"\\") { - let b2,b3,b4,b5; + const b2 = text(\` + \`); + let b4,b5,b6,b7; if (ctx['state'].flag) { - b2 = block2(); + b4 = block4(); } else { - b3 = block3(); - } - b4 = comp1({}, key + \`__1\`, node, this, null); - if (ctx['state'].flag) { b5 = block5(); } - return block1([], [b2, b3, b4, b5]); + b6 = comp1({}, key + \`__1\`, node, this, null); + if (ctx['state'].flag) { + b7 = block7(); + } + const b3 = block3([], [b4, b5, b6, b7]); + return multi([b2, b3]); } }" `; @@ -772,17 +808,22 @@ exports[`basics t-elif works with t-component 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`
    somediv
    \`); + let block3 = createBlock(\`
    + +
    \`); + let block4 = createBlock(\`
    somediv
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['state'].flag) { - b2 = block2(); + b4 = block4(); } else if (!ctx['state'].flag) { - b3 = comp1({}, key + \`__1\`, node, this, null); + b5 = comp1({}, key + \`__1\`, node, this, null); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -806,17 +847,22 @@ exports[`basics t-else with empty string works with t-component 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`
    somediv
    \`); + let block3 = createBlock(\`
    + +
    \`); + let block4 = createBlock(\`
    somediv
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['state'].flag) { - b2 = block2(); + b4 = block4(); } else { - b3 = comp1({}, key + \`__1\`, node, this, null); + b5 = comp1({}, key + \`__1\`, node, this, null); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -840,17 +886,22 @@ exports[`basics t-else works with t-component 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); - let block2 = createBlock(\`
    somediv
    \`); + let block3 = createBlock(\`
    + +
    \`); + let block4 = createBlock(\`
    somediv
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['state'].flag) { - b2 = block2(); + b4 = block4(); } else { - b3 = comp1({}, key + \`__1\`, node, this, null); + b5 = comp1({}, key + \`__1\`, node, this, null); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -906,16 +957,22 @@ exports[`basics t-key on a component with t-if, and a sibling component 1`] = ` const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp2 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (false) { const tKey_1 = 'str'; - b2 = toggler(tKey_1, comp1({}, tKey_1 + key + \`__1\`, node, this, null)); + b4 = toggler(tKey_1, comp1({}, tKey_1 + key + \`__1\`, node, this, null)); } - b3 = comp2({}, key + \`__2\`, node, this, null); - return block1([], [b2, b3]); + b5 = comp2({}, key + \`__2\`, node, this, null); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -939,15 +996,21 @@ exports[`basics text after a conditional component 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2; + const b2 = text(\` + \`); + let b4; if (ctx['state'].hasChild) { - b2 = comp1({}, key + \`__1\`, node, this, null); + b4 = comp1({}, key + \`__1\`, node, this, null); } let txt1 = ctx['state'].text; - return block1([txt1], [b2]); + const b3 = block3([txt1], [b4]); + return multi([b2, b3]); } }" `; @@ -1036,12 +1099,17 @@ exports[`basics update props of component without concrete own node 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, true, false); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); const tKey_1 = ctx['childProps'].key; - const b2 = toggler(tKey_1, comp1(Object.assign({}, ctx['childProps']), tKey_1 + key + \`__1\`, node, this, null)); - return block1([], [b2]); + const b4 = toggler(tKey_1, comp1(Object.assign({}, ctx['childProps']), tKey_1 + key + \`__1\`, node, this, null)); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -1053,8 +1121,11 @@ exports[`basics update props of component without concrete own node 2`] = ` const comp1 = app.createComponent(\`Custom\`, true, false, false, false); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); const tKey_1 = ctx['props'].subKey; - return toggler(tKey_1, comp1({key: ctx['props'].key,subKey: ctx['props'].subKey}, tKey_1 + key + \`__1\`, node, this, null)); + const b3 = toggler(tKey_1, comp1({key: ctx['props'].key,subKey: ctx['props'].subKey}, tKey_1 + key + \`__1\`, node, this, null)); + return multi([b2, b3]); } }" `; @@ -1064,12 +1135,17 @@ exports[`basics update props of component without concrete own node 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    __
    \`); + let block3 = createBlock(\`
    + __ +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['props'].key; let txt2 = ctx['props'].subKey; - return block1([txt1, txt2]); + const b3 = block3([txt1, txt2]); + return multi([b2, b3]); } }" `; @@ -1081,14 +1157,22 @@ exports[`basics updating a component with t-foreach as root 1`] = ` let { prepareList, withKey } = helpers; return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['items']);; - for (let i1 = 0; i1 < l_block1; i1++) { - ctx[\`item\`] = v_block1[i1]; + const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['items']);; + for (let i1 = 0; i1 < l_block3; i1++) { + ctx[\`item\`] = v_block3[i1]; const key1 = ctx['item']; - c_block1[i1] = withKey(text(ctx['item']), key1); + const b5 = text(\` + \`); + const b6 = text(ctx['item']); + const b7 = text(\` + \`); + c_block3[i1] = withKey(multi([b5, b6, b7]), key1); } - return list(c_block1); + const b3 = list(c_block3); + return multi([b2, b3]); } }" `; @@ -1248,11 +1332,16 @@ exports[`support svg components add proper namespace to svg 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`GComp\`, true, false, false, true); - let block1 = createBlock(\`\`); + let block3 = createBlock(\` + + \`); return function template(ctx, node, key = \\"\\") { - const b2 = comp1({}, key + \`__1\`, node, this, null); - return block1([], [b2]); + const b2 = text(\` + \`); + const b4 = comp1({}, key + \`__1\`, node, this, null); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -1262,10 +1351,15 @@ exports[`support svg components add proper namespace to svg 2`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`\`); + let block3 = createBlock(\` + + \`); return function template(ctx, node, key = \\"\\") { - return block1(); + const b2 = text(\` + \`); + const b3 = block3(); + return multi([b2, b3]); } }" `; @@ -1276,20 +1370,32 @@ exports[`t-out in components can render list of t-out 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { prepareList, safeOutput, withKey } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['state'].items);; - for (let i1 = 0; i1 < l_block2; i1++) { - ctx[\`item\`] = v_block2[i1]; + const [k_block4, v_block4, l_block4, c_block4] = prepareList(ctx['state'].items);; + for (let i1 = 0; i1 < l_block4; i1++) { + ctx[\`item\`] = v_block4[i1]; const key1 = ctx['item']; - const b4 = text(ctx['item']); - const b5 = safeOutput(ctx['item']); - c_block2[i1] = withKey(multi([b4, b5]), key1); + const b6 = text(\` + \`); + const b7 = text(ctx['item']); + const b8 = text(\` + \`); + const b9 = safeOutput(ctx['item']); + const b10 = text(\` + \`); + c_block4[i1] = withKey(multi([b6, b7, b8, b9, b10]), key1); } - const b2 = list(c_block2); - return block1([], [b2]); + ctx = ctx.__proto__; + const b4 = list(c_block4); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -1301,9 +1407,15 @@ exports[`t-out in components can switch the contents of two t-out repeatedly 1`] let { safeOutput } = helpers; return function template(ctx, node, key = \\"\\") { - const b2 = safeOutput(ctx['state'].a); - const b3 = safeOutput(ctx['state'].b); - return multi([b2, b3]); + const b2 = text(\` + \`); + const b3 = safeOutput(ctx['state'].a); + const b4 = text(\` + \`); + const b5 = safeOutput(ctx['state'].b); + const b6 = text(\` + \`); + return multi([b2, b3, b4, b5, b6]); } }" `; diff --git a/tests/components/__snapshots__/concurrency.test.ts.snap b/tests/components/__snapshots__/concurrency.test.ts.snap index 18df8e4c..385134c4 100644 --- a/tests/components/__snapshots__/concurrency.test.ts.snap +++ b/tests/components/__snapshots__/concurrency.test.ts.snap @@ -31,14 +31,22 @@ exports[`Cascading renders after microtaskTick 2`] = ` const comp1 = app.createComponent(\`Element\`, true, false, false, false); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['state']);; - for (let i1 = 0; i1 < l_block1; i1++) { - ctx[\`elem\`] = v_block1[i1]; + const [k_block3, v_block3, l_block3, c_block3] = prepareList(ctx['state']);; + for (let i1 = 0; i1 < l_block3; i1++) { + ctx[\`elem\`] = v_block3[i1]; const key1 = ctx['elem'].id; - c_block1[i1] = withKey(comp1({id: ctx['elem'].id}, key + \`__1__\${key1}\`, node, this, null), key1); + const b5 = text(\` + \`); + const b6 = comp1({id: ctx['elem'].id}, key + \`__1__\${key1}\`, node, this, null); + const b7 = text(\` + \`); + c_block3[i1] = withKey(multi([b5, b6, b7]), key1); } - return list(c_block1); + const b3 = list(c_block3); + return multi([b2, b3]); } }" `; @@ -143,11 +151,16 @@ exports[`calling render in destroy 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['props'].fromA; - return block1([txt1]); + const b3 = block3([txt1]); + return multi([b2, b3]); } }" `; @@ -593,13 +606,20 @@ exports[`concurrent renderings scenario 9 1`] = ` const comp1 = app.createComponent(\`ComponentB\`, true, false, false, false); const comp2 = app.createComponent(\`ComponentC\`, true, false, false, false); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + + +
    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['state'].fromA; - const b2 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null); - const b3 = comp2({fromA: ctx['state'].fromA}, key + \`__2\`, node, this, null); - return block1([txt1], [b2, b3]); + const b4 = comp1({fromA: ctx['state'].fromA}, key + \`__1\`, node, this, null); + const b5 = comp2({fromA: ctx['state'].fromA}, key + \`__2\`, node, this, null); + const b3 = block3([txt1], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -761,15 +781,21 @@ exports[`concurrent renderings scenario 13 1`] = ` const comp1 = app.createComponent(\`Child\`, true, false, false, true); const comp2 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; - b2 = comp1({}, key + \`__1\`, node, this, null); + const b2 = text(\` + \`); + let b4,b5; + b4 = comp1({}, key + \`__1\`, node, this, null); if (ctx['state'].bool) { - b3 = comp2({}, key + \`__2\`, node, this, null); + b5 = comp2({}, key + \`__2\`, node, this, null); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -823,13 +849,20 @@ exports[`concurrent renderings scenario 14 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`

    \`); + let block3 = createBlock(\`

    + + + +

    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['props'].fromA; let txt2 = ctx['props'].fromB; let txt3 = ctx['state'].fromC; - return block1([txt1, txt2, txt3]); + const b3 = block3([txt1, txt2, txt3]); + return multi([b2, b3]); } }" `; @@ -869,13 +902,20 @@ exports[`concurrent renderings scenario 15 3`] = ` ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`

    \`); + let block3 = createBlock(\`

    + + + +

    \`); return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['props'].fromA; let txt2 = ctx['props'].fromB; let txt3 = ctx['state'].fromC; - return block1([txt1, txt2, txt3]); + const b3 = block3([txt1, txt2, txt3]); + return multi([b2, b3]); } }" `; @@ -911,17 +951,20 @@ exports[`concurrent renderings scenario 16 3`] = ` const comp1 = app.createComponent(\`D\`, true, false, false, true); return function template(ctx, node, key = \\"\\") { - let b2,b3,b4,b5,b6,b7,b8; - b2 = text(ctx['props'].fromA); - b3 = text(\`:\`); - b4 = text(ctx['props'].fromB); - b5 = text(\`:\`); - b6 = text(ctx['state'].fromC); - b7 = text(\`: \`); + let b2,b3,b4,b5,b6,b7,b8,b9; + b2 = text(\` + \`); + b3 = text(ctx['props'].fromA); + b4 = text(\`:\`); + b5 = text(ctx['props'].fromB); + b6 = text(\`:\`); + b7 = text(ctx['state'].fromC); + b8 = text(\`: + \`); if (ctx['state'].fromC===13) { - b8 = comp1({}, key + \`__1\`, node, this, null); + b9 = comp1({}, key + \`__1\`, node, this, null); } - return multi([b2, b3, b4, b5, b6, b7, b8]); + return multi([b2, b3, b4, b5, b6, b7, b8, b9]); } }" `; @@ -945,14 +988,18 @@ exports[`creating two async components, scenario 1 1`] = ` const comp2 = app.createComponent(\`ChildB\`, true, false, false, true); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2,b3,b4,b5; + b2 = text(\` + \`); if (ctx['state'].flagA) { - b2 = comp1({}, key + \`__1\`, node, this, null); + b3 = comp1({}, key + \`__1\`, node, this, null); } + b4 = text(\` + \`); if (ctx['state'].flagB) { - b3 = comp2({}, key + \`__2\`, node, this, null); + b5 = comp2({}, key + \`__2\`, node, this, null); } - return multi([b2, b3]); + return multi([b2, b3, b4, b5]); } }" `; @@ -991,15 +1038,21 @@ exports[`creating two async components, scenario 2 1`] = ` const comp1 = app.createComponent(\`ChildA\`, true, false, false, false); const comp2 = app.createComponent(\`ChildB\`, true, false, false, false); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; - b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null); + const b2 = text(\` + \`); + let b4,b5; + b4 = 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); + b5 = comp2({val: ctx['state'].valB}, key + \`__2\`, node, this, null); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -1039,15 +1092,21 @@ exports[`creating two async components, scenario 3 (patching in the same frame) const comp1 = app.createComponent(\`ChildA\`, true, false, false, false); const comp2 = app.createComponent(\`ChildB\`, true, false, false, false); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; - b2 = comp1({val: ctx['state'].valA}, key + \`__1\`, node, this, null); + const b2 = text(\` + \`); + let b4,b5; + b4 = 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); + b5 = comp2({val: ctx['state'].valB}, key + \`__2\`, node, this, null); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -1475,11 +1534,19 @@ exports[`destroyed component causes other soon to be destroyed component to rere return function template(ctx, node, key = \\"\\") { let b2,b3; - b2 = text(\` A \`); + b2 = text(\` + A + \`); if (ctx['state'].flag) { - const b4 = comp1({value: ctx['state'].valueB}, key + \`__1\`, node, this, null); - const b5 = comp2({value: ctx['state'].valueC}, key + \`__2\`, node, this, null); - b3 = multi([b4, b5]); + const b4 = text(\` + \`); + const b5 = comp1({value: ctx['state'].valueB}, key + \`__1\`, node, this, null); + const b6 = text(\` + \`); + const b7 = comp2({value: ctx['state'].valueC}, key + \`__2\`, node, this, null); + const b8 = text(\` + \`); + b3 = multi([b4, b5, b6, b7, b8]); } return multi([b2, b3]); } @@ -1542,14 +1609,19 @@ exports[`destroying/recreating a subwidget with different props (if start is not let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, false); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2; + const b2 = text(\` + \`); + let b4; if (ctx['state'].val>1) { - b2 = comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null); + b4 = comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null); } - return block1([], [b2]); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -1597,14 +1669,17 @@ exports[`properly behave when destroyed/unmounted while rendering 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, false); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    \`); return function template(ctx, node, key = \\"\\") { - let b2; + const b2 = text(\` + \`); + let b4; if (ctx['state'].flag) { - b2 = comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null); + b4 = comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null); } - return block1([], [b2]); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -1643,15 +1718,21 @@ exports[`rendering component again in next microtick 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2; + const b2 = text(\` + \`); + let b4; let hdlr1 = [ctx['onClick'], ctx]; if (ctx['env'].config.flag) { - b2 = comp1({}, key + \`__1\`, node, this, null); + b4 = comp1({}, key + \`__1\`, node, this, null); } - return block1([hdlr1], [b2]); + const b3 = block3([hdlr1], [b4]); + return multi([b2, b3]); } }" `; @@ -1773,12 +1854,16 @@ exports[`t-foreach with dynamic async component 1`] = ` ctx[\`arr\`] = v_block1[i1]; ctx[\`arr_index\`] = i1; const key1 = ctx['arr_index']; - let b3; + let b3,b4,b5; + b3 = text(\` + \`); if (ctx['arr']) { const Comp1 = ctx['myComp']; - b3 = toggler(Comp1, comp1({key: ctx['arr'][0]}, key + \`__1__\${key1}\`, node, this, Comp1)); + b4 = toggler(Comp1, comp1({key: ctx['arr'][0]}, key + \`__1__\${key1}\`, node, this, Comp1)); } - c_block1[i1] = withKey(multi([b3]), key1); + b5 = text(\` + \`); + c_block1[i1] = withKey(multi([b3, b4, b5]), key1); } return list(c_block1); } diff --git a/tests/components/__snapshots__/error_handling.test.ts.snap b/tests/components/__snapshots__/error_handling.test.ts.snap index bd70be30..7c65c420 100644 --- a/tests/components/__snapshots__/error_handling.test.ts.snap +++ b/tests/components/__snapshots__/error_handling.test.ts.snap @@ -73,16 +73,26 @@ exports[`basics simple catchError 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Boom\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['error']) { - b2 = text(\`Error\`); + b4 = text(\`Error\`); } else { - b3 = comp1({}, key + \`__1\`, node, this, null); + const b6 = text(\` + \`); + const b7 = comp1({}, key + \`__1\`, node, this, null); + const b8 = text(\` + \`); + b5 = multi([b6, b7, b8]); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -108,12 +118,16 @@ exports[`can catch errors an error in onWillDestroy 1`] = ` const comp1 = app.createComponent(\`Child\`, true, false, false, true); return function template(ctx, node, key = \\"\\") { - let b2,b3; - b2 = text(ctx['state'].value); + let b2,b3,b4,b5; + b2 = text(\` + \`); + b3 = text(ctx['state'].value); + b4 = text(\` + \`); if (ctx['state'].hasChild) { - b3 = comp1({}, key + \`__1\`, node, this, null); + b5 = comp1({}, key + \`__1\`, node, this, null); } - return multi([b2, b3]); + return multi([b2, b3, b4, b5]); } }" `; @@ -138,12 +152,16 @@ exports[`can catch errors an error in onWillDestroy, variation 1`] = ` const comp1 = app.createComponent(\`Child\`, true, false, false, true); return function template(ctx, node, key = \\"\\") { - let b2,b3; - b2 = text(ctx['state'].value); + let b2,b3,b4,b5; + b2 = text(\` + \`); + b3 = text(ctx['state'].value); + b4 = text(\` + \`); if (ctx['state'].hasChild) { - b3 = comp1({}, key + \`__1\`, node, this, null); + b5 = comp1({}, key + \`__1\`, node, this, null); } - return multi([b2, b3]); + return multi([b2, b3, b4, b5]); } }" `; @@ -180,15 +198,20 @@ exports[`can catch errors can catch an error in a component render function 1`] const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, false); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); function slot1(ctx, node, key = \\"\\") { return comp1({flag: ctx['state'].flag}, key + \`__1\`, node, this, null); } return function template(ctx, node, key = \\"\\") { - const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null); - return block1([], [b3]); + const b2 = text(\` + \`); + const b5 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null); + const b3 = block3([], [b5]); + return multi([b2, b3]); } }" `; @@ -199,16 +222,21 @@ exports[`can catch errors can catch an error in a component render function 2`] let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['state'].error) { - b2 = text(\`Error handled\`); + b4 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default', false, {}); + b5 = callSlot(ctx, node, key, 'default', false, {}); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -235,7 +263,9 @@ exports[`can catch errors can catch an error in the constructor call of a compon const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); function slot1(ctx, node, key = \\"\\") { return comp1({}, key + \`__1\`, node, this, null); @@ -254,7 +284,9 @@ exports[`can catch errors can catch an error in the constructor call of a compon let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let b2,b3; @@ -277,7 +309,9 @@ exports[`can catch errors can catch an error in the constructor call of a compon const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); function slot1(ctx, node, key = \\"\\") { const b3 = comp1({}, key + \`__1\`, node, this, null); @@ -298,7 +332,9 @@ exports[`can catch errors can catch an error in the constructor call of a compon let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let b2,b3; @@ -359,15 +395,20 @@ exports[`can catch errors can catch an error in the initial call of a component const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); function slot1(ctx, node, key = \\"\\") { return comp1({}, key + \`__1\`, node, this, null); } return function template(ctx, node, key = \\"\\") { - const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null); - return block1([], [b3]); + const b2 = text(\` + \`); + const b5 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null); + const b3 = block3([], [b5]); + return multi([b2, b3]); } }" `; @@ -378,16 +419,21 @@ exports[`can catch errors can catch an error in the initial call of a component let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['state'].error) { - b2 = text(\`Error handled\`); + b4 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default', false, {}); + b5 = callSlot(ctx, node, key, 'default', false, {}); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -414,18 +460,23 @@ exports[`can catch errors can catch an error in the initial call of a component const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); function slot1(ctx, node, key = \\"\\") { return comp1({}, key + \`__1\`, node, this, null); } return function template(ctx, node, key = \\"\\") { - let b3; + const b2 = text(\` + \`); + let b5; if (ctx['state'].flag) { - b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null); + b5 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null); } - return block1([], [b3]); + const b3 = block3([], [b5]); + return multi([b2, b3]); } }" `; @@ -436,16 +487,21 @@ exports[`can catch errors can catch an error in the initial call of a component let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['state'].error) { - b2 = text(\`Error handled\`); + b4 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default', false, {}); + b5 = callSlot(ctx, node, key, 'default', false, {}); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -497,7 +553,9 @@ exports[`can catch errors can catch an error in the mounted call (in child of ch let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Boom\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let b2,b3; @@ -530,7 +588,9 @@ exports[`can catch errors can catch an error in the mounted call (in root compon let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let b2,b3; @@ -565,7 +625,9 @@ exports[`can catch errors can catch an error in the mounted call 1`] = ` const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); function slot1(ctx, node, key = \\"\\") { return comp1({}, key + \`__1\`, node, this, null); @@ -584,7 +646,9 @@ exports[`can catch errors can catch an error in the mounted call 2`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let b2,b3; @@ -619,16 +683,22 @@ exports[`can catch errors can catch an error in the willPatch call 1`] = ` const comp1 = app.createComponent(\`ErrorComponent\`, true, false, false, false); const comp2 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + + +
    \`); function slot1(ctx, node, key = \\"\\") { return comp1({message: ctx['state'].message}, key + \`__1\`, node, this, null); } return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); let txt1 = ctx['state'].message; - const b3 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null); - return block1([txt1], [b3]); + const b5 = comp2({slots: markRaw({'default': {__render: slot1, __ctx: ctx}})}, key + \`__2\`, node, this, null); + const b3 = block3([txt1], [b5]); + return multi([b2, b3]); } }" `; @@ -639,16 +709,21 @@ exports[`can catch errors can catch an error in the willPatch call 2`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['state'].error) { - b2 = text(\`Error handled\`); + b4 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default', false, {}); + b5 = callSlot(ctx, node, key, 'default', false, {}); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -694,16 +769,21 @@ exports[`can catch errors can catch an error in the willStart call 2`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['state'].error) { - b2 = text(\`Error handled\`); + b4 = text(\`Error handled\`); } else { - b3 = callSlot(ctx, node, key, 'default', false, {}); + b5 = callSlot(ctx, node, key, 'default', false, {}); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -730,7 +810,9 @@ exports[`can catch errors can catch an error origination from a child's willStar const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); function slot1(ctx, node, key = \\"\\") { const b3 = comp1({}, key + \`__1\`, node, this, null); @@ -751,7 +833,9 @@ exports[`can catch errors can catch an error origination from a child's willStar let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let b2,b3; @@ -797,16 +881,26 @@ exports[`can catch errors catchError in catchError 1`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + const b2 = text(\` + \`); + let b4,b5; if (ctx['error']) { - b2 = text(\`Error\`); + b4 = text(\`Error\`); } else { - b3 = comp1({}, key + \`__1\`, node, this, null); + const b6 = text(\` + \`); + const b7 = comp1({}, key + \`__1\`, node, this, null); + const b8 = text(\` + \`); + b5 = multi([b6, b7, b8]); } - return block1([], [b2, b3]); + const b3 = block3([], [b4, b5]); + return multi([b2, b3]); } }" `; @@ -817,11 +911,16 @@ exports[`can catch errors catchError in catchError 2`] = ` let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Boom\`, true, false, false, true); - let block1 = createBlock(\`
    \`); + let block3 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - const b2 = comp1({}, key + \`__1\`, node, this, null); - return block1([], [b2]); + const b2 = text(\` + \`); + const b4 = comp1({}, key + \`__1\`, node, this, null); + const b3 = block3([], [b4]); + return multi([b2, b3]); } }" `; @@ -849,21 +948,34 @@ exports[`can catch errors catching error, rethrow, render parent -- a main comp const comp2 = app.createComponent(\`ErrorHandler\`, true, true, false, false); function slot1(ctx, node, key = \\"\\") { + const b7 = text(\` + \`); const Comp1 = ctx['cp'].Comp; - return toggler(Comp1, comp1({}, key + \`__1\`, node, this, Comp1)); + const b8 = toggler(Comp1, comp1({}, key + \`__1\`, node, this, Comp1)); + const b9 = text(\` + \`); + return multi([b7, b8, b9]); } return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block1, v_block1, l_block1, c_block1] = prepareList(Object.values(ctx['state'].cps));; - for (let i1 = 0; i1 < l_block1; i1++) { - ctx[\`cp\`] = v_block1[i1]; + const [k_block3, v_block3, l_block3, c_block3] = prepareList(Object.values(ctx['state'].cps));; + for (let i1 = 0; i1 < l_block3; i1++) { + ctx[\`cp\`] = v_block3[i1]; const key1 = ctx['cp'].id; + const b5 = text(\` + \`); const v1 = ctx['cp']; const ctx1 = capture(ctx); - c_block1[i1] = withKey(comp2({onError: ()=>this.cleanUp(v1.id),slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2__\${key1}\`, node, this, null), key1); + const b10 = comp2({onError: ()=>this.cleanUp(v1.id),slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2__\${key1}\`, node, this, null); + const b11 = text(\` + \`); + c_block3[i1] = withKey(multi([b5, b10, b11]), key1); } - return list(c_block1); + const b3 = list(c_block3); + return multi([b2, b3]); } }" `; @@ -927,21 +1039,37 @@ exports[`can catch errors catching in child makes parent render 1`] = ` const comp2 = app.createComponent(\`Catch\`, true, true, false, false); function slot1(ctx, node, key = \\"\\") { + const b7 = text(\` + \`); const Comp1 = ctx['elem'][1]; - return toggler(Comp1, comp1({id: ctx['elem'][0]}, key + \`__1\`, node, this, Comp1)); + const b8 = toggler(Comp1, comp1({id: ctx['elem'][0]}, key + \`__1\`, node, this, Comp1)); + const b9 = text(\` + \`); + return multi([b7, b8, b9]); } return function template(ctx, node, key = \\"\\") { + const b2 = text(\` + \`); ctx = Object.create(ctx); - const [k_block1, v_block1, l_block1, c_block1] = prepareList(Object.entries(this.elements));; - for (let i1 = 0; i1 < l_block1; i1++) { - ctx[\`elem\`] = v_block1[i1]; + const [k_block3, v_block3, l_block3, c_block3] = prepareList(Object.entries(this.elements));; + for (let i1 = 0; i1 < l_block3; i1++) { + ctx[\`elem\`] = v_block3[i1]; const key1 = ctx['elem'][0]; + const b5 = text(\` + \`); const v1 = ctx['elem']; const ctx1 = capture(ctx); - c_block1[i1] = withKey(comp2({onError: (_error)=>this.onError(v1[0],_error),slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2__\${key1}\`, node, this, null), key1); + const b10 = comp2({onError: (_error)=>this.onError(v1[0],_error),slots: markRaw({'default': {__render: slot1, __ctx: ctx1}})}, key + \`__2__\${key1}\`, node, this, null); + const b11 = text(\` + \`); + c_block3[i1] = withKey(multi([b5, b10, b11]), key1); } - return list(c_block1); + ctx = ctx.__proto__; + const b3 = list(c_block3); + const b12 = text(\` + \`); + return multi([b2, b3, b12]); } }" `; @@ -994,7 +1122,10 @@ exports[`can catch errors error in mounted on a component with a sibling (proper const comp2 = app.createComponent(\`ErrorComponent\`, true, false, false, true); const comp3 = app.createComponent(\`ErrorBoundary\`, true, true, false, true); - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + + +
    \`); function slot1(ctx, node, key = \\"\\") { return comp2({}, key + \`__2\`, node, this, null); @@ -1025,7 +1156,9 @@ exports[`can catch errors error in mounted on a component with a sibling (proper let { text, createBlock, list, multi, html, toggler, comment } = bdom; let { callSlot } = helpers; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { let b2,b3; @@ -1069,16 +1202,28 @@ exports[`can catch errors onError in class inheritance is called if rethrown 2`] ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2,b6; if (!ctx['state'].error) { - b2 = text(this.will.crash); + const b3 = text(\` + \`); + const b4 = text(this.will.crash); + const b5 = text(\` + \`); + b2 = multi([b3, b4, b5]); } else { - b3 = text(ctx['state'].error); + const b7 = text(\` + \`); + const b8 = text(ctx['state'].error); + const b9 = text(\` + \`); + b6 = multi([b7, b8, b9]); } - return block1([], [b2, b3]); + return block1([], [b2, b6]); } }" `; @@ -1100,16 +1245,28 @@ exports[`can catch errors onError in class inheritance is not called if no rethr ) { let { text, createBlock, list, multi, html, toggler, comment } = bdom; - let block1 = createBlock(\`
    \`); + let block1 = createBlock(\`
    + +
    \`); return function template(ctx, node, key = \\"\\") { - let b2,b3; + let b2,b6; if (!ctx['state'].error) { - b2 = text(this.will.crash); + const b3 = text(\` + \`); + const b4 = text(this.will.crash); + const b5 = text(\` + \`); + b2 = multi([b3, b4, b5]); } else { - b3 = text(ctx['state'].error); + const b7 = text(\` + \`); + const b8 = text(ctx['state'].error); + const b9 = text(\` + \`); + b6 = multi([b7, b8, b9]); } - return block1([], [b2, b3]); + return block1([], [b2, b6]); } }" `; diff --git a/tests/components/__snapshots__/event_handling.test.ts.snap b/tests/components/__snapshots__/event_handling.test.ts.snap index 579a1a49..a69f7adc 100644 --- a/tests/components/__snapshots__/event_handling.test.ts.snap +++ b/tests/components/__snapshots__/event_handling.test.ts.snap @@ -64,14 +64,20 @@ exports[`event handling input blur event is not called if component is destroyed let { text, createBlock, list, multi, html, toggler, comment } = bdom; const comp1 = app.createComponent(\`Child\`, true, false, false, true); - let block1 = createBlock(\`