mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
0f2192604c
This commit reintroduces some tests for the t-set directive and make
them pass. For that, it was necessary to adapt the qweb compiler in
order to get the following behaviors:
A t-set can affect parent contexts (up to the first parent tagged as
boundary) when the key changed is found in one of the parent contexts.
Some context are marked as boundaries in such a way that
- rendering contexts (e.g. components) cannot be modified via a t-set.
- a t-set in a t-call body or in a called template can never change a
context above the t-call context.
Code prettification has been done.
Snapshots have been modified.
528 lines
18 KiB
Plaintext
528 lines
18 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`t-foreach does not pollute the rendering context 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = ctx['item'];
|
|
c_block2[i1] = withKey(text(ctx['item']), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach iterate on items (on a element node) 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = ctx['item'];
|
|
let d1 = ctx['item'];
|
|
c_block2[i1] = withKey(block3([d1]), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach iterate on items 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
ctx[\`item_index\`] = i1;
|
|
ctx[\`item_value\`] = k_block2[i1];
|
|
let key1 = ctx['item'];
|
|
let b4 = text(\` [\`);
|
|
let b5 = text(ctx['item_index']);
|
|
let b6 = text(\`: \`);
|
|
let b7 = text(ctx['item']);
|
|
let b8 = text(\` \`);
|
|
let b9 = text(ctx['item_value']);
|
|
let b10 = text(\`] \`);
|
|
c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9, b10]), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach iterate, dict param 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
ctx[\`item_index\`] = i1;
|
|
ctx[\`item_value\`] = k_block2[i1];
|
|
let key1 = ctx['item_index'];
|
|
let b4 = text(\` [\`);
|
|
let b5 = text(ctx['item_index']);
|
|
let b6 = text(\`: \`);
|
|
let b7 = text(ctx['item']);
|
|
let b8 = text(\` \`);
|
|
let b9 = text(ctx['item_value']);
|
|
let b10 = text(\`] \`);
|
|
c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9, b10]), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach iterate, position 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
ctx[\`elem_first\`] = i1 === 0;
|
|
ctx[\`elem_last\`] = i1 === v_block2.length - 1;
|
|
ctx[\`elem_index\`] = i1;
|
|
let key1 = ctx['elem'];
|
|
let b4,b5,b6,b7,b8,b9;
|
|
b4 = text(\` -\`);
|
|
if (ctx['elem_first']) {
|
|
b5 = text(\` first\`);
|
|
}
|
|
if (ctx['elem_last']) {
|
|
b6 = text(\` last\`);
|
|
}
|
|
b7 = text(\` (\`);
|
|
b8 = text(ctx['elem_index']);
|
|
b9 = text(\`) \`);
|
|
c_block2[i1] = withKey(multi([b4, b5, b6, b7, b8, b9]), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach simple iteration (in a node) 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = ctx['item'];
|
|
c_block2[i1] = withKey(text(ctx['item']), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach simple iteration 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = ctx['item'];
|
|
c_block1[i1] = withKey(text(ctx['item']), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach simple iteration with two nodes inside 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block3 = createBlock(\`<span>a<block-text-0/></span>\`);
|
|
let block4 = createBlock(\`<span>b<block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = ctx['item'];
|
|
let d1 = ctx['item'];
|
|
let b3 = block3([d1]);
|
|
let d2 = ctx['item'];
|
|
let b4 = block4([d2]);
|
|
c_block1[i1] = withKey(multi([b3, b4]), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach t-call with body in t-foreach in t-foreach 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2 = text(\` [\`);
|
|
let b3 = text(ctx['a']);
|
|
let b4 = text(\`] [\`);
|
|
let b5 = text(ctx['b']);
|
|
let b6 = text(\`] [\`);
|
|
let b7 = text(ctx['c']);
|
|
let b8 = text(\`] \`);
|
|
return multi([b2, b3, b4, b5, b6, b7, b8]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
const callTemplate_2 = getTemplate(\`sub\`);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span></div>\`);
|
|
let block6 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
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];
|
|
ctx[\`a_first\`] = i1 === 0;
|
|
ctx[\`a_last\`] = i1 === v_block2.length - 1;
|
|
ctx[\`a_index\`] = i1;
|
|
ctx[\`a_value\`] = k_block2[i1];
|
|
let key1 = ctx['a'];
|
|
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];
|
|
ctx[\`b_first\`] = i2 === 0;
|
|
ctx[\`b_last\`] = i2 === v_block4.length - 1;
|
|
ctx[\`b_index\`] = i2;
|
|
ctx[\`b_value\`] = k_block4[i2];
|
|
let key2 = ctx['b'];
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1;
|
|
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
|
|
c_block4[i2] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}__\${key2}\`), key2);
|
|
ctx = ctx.__proto__;
|
|
}
|
|
ctx = ctx.__proto__;
|
|
let b4 = list(c_block4);
|
|
let d1 = ctx['c'];
|
|
let b6 = block6([d1]);
|
|
c_block2[i1] = withKey(multi([b4, b6]), key1);
|
|
}
|
|
ctx = ctx.__proto__;
|
|
let b2 = list(c_block2);
|
|
let d2 = ctx['a'];
|
|
let d3 = ctx['b'];
|
|
let d4 = ctx['c'];
|
|
return block1([d2, d3, d4], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
|
|
let b2 = text(\` [\`);
|
|
let b3 = text(ctx['a']);
|
|
let b4 = text(\`] [\`);
|
|
let b5 = text(ctx['b']);
|
|
let b6 = text(\`] [\`);
|
|
let b7 = text(ctx['c']);
|
|
let b8 = text(\`] \`);
|
|
return multi([b2, b3, b4, b5, b6, b7, b8]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
const callTemplate_2 = getTemplate(\`sub\`);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span></div>\`);
|
|
let block6 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
ctx[\`a_first\`] = i1 === 0;
|
|
ctx[\`a_last\`] = i1 === v_block2.length - 1;
|
|
ctx[\`a_index\`] = i1;
|
|
ctx[\`a_value\`] = k_block2[i1];
|
|
let key1 = ctx['a'];
|
|
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];
|
|
ctx[\`b_first\`] = i2 === 0;
|
|
ctx[\`b_last\`] = i2 === v_block4.length - 1;
|
|
ctx[\`b_index\`] = i2;
|
|
ctx[\`b_value\`] = k_block4[i2];
|
|
let key2 = ctx['b'];
|
|
c_block4[i2] = withKey(callTemplate_2(ctx, node, key + \`__1__\${key1}__\${key2}\`), key2);
|
|
}
|
|
ctx = ctx.__proto__;
|
|
let b4 = list(c_block4);
|
|
let d1 = ctx['c'];
|
|
let b6 = block6([d1]);
|
|
c_block2[i1] = withKey(multi([b4, b6]), key1);
|
|
}
|
|
ctx = ctx.__proto__;
|
|
let b2 = list(c_block2);
|
|
let d2 = ctx['a'];
|
|
let d3 = ctx['b'];
|
|
let d4 = ctx['c'];
|
|
return block1([d2, d3, d4], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach t-foreach in t-foreach 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = ctx['number'];
|
|
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];
|
|
let key2 = ctx['letter'];
|
|
let b5 = text(\` [\`);
|
|
let b6 = text(ctx['number']);
|
|
let b7 = text(ctx['letter']);
|
|
let b8 = text(\`] \`);
|
|
c_block3[i2] = withKey(multi([b5, b6, b7, b8]), key2);
|
|
}
|
|
ctx = ctx.__proto__;
|
|
c_block2[i1] = withKey(list(c_block3), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach t-foreach with t-if inside (no external node) 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = ctx['elem'].id;
|
|
let b3;
|
|
if (ctx['elem'].id<3) {
|
|
let d1 = ctx['elem'].text;
|
|
b3 = block3([d1]);
|
|
}
|
|
c_block1[i1] = withKey(multi([b3]), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach t-foreach with t-if inside 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block4 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = ctx['elem'].id;
|
|
let b4;
|
|
if (ctx['elem'].id<3) {
|
|
let d1 = ctx['elem'].text;
|
|
b4 = block4([d1]);
|
|
}
|
|
c_block2[i1] = withKey(multi([b4]), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach throws error if invalid loop expression 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<span/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['abc']);
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
ctx[\`item\`] = v_block2[i1];
|
|
ctx[\`item_index\`] = i1;
|
|
let key1 = ctx['item'];
|
|
c_block2[i1] = withKey(block3(), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach warn if no key in some case 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
let key1 = i1;
|
|
let d1 = ctx['item'];
|
|
c_block2[i1] = withKey(block3([d1]), key1);
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-foreach with t-memo 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
|
let assign = Object.assign;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<p><block-text-0/><block-text-1/></p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let cache = ctx.cache || {};
|
|
let nextCache = ctx.cache = {};
|
|
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];
|
|
let key1 = ctx['item'].id;
|
|
let memo1 = [ctx['item'].x]
|
|
let vnode1 = cache[key1];
|
|
if (vnode1) {
|
|
if (shallowEqual(vnode1.memo, memo1)) {
|
|
c_block2[i1] = vnode1;
|
|
nextCache[key1] = vnode1;
|
|
continue;
|
|
}
|
|
}
|
|
let d1 = ctx['item'].x;
|
|
let d2 = ctx['item'].y;
|
|
c_block2[i1] = withKey(block3([d1, d2]), key1);
|
|
nextCache[key1] = assign(c_block2[i1], {memo: memo1});
|
|
}
|
|
let b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|