Files
owl/tests/components/__snapshots__/t_call.test.ts.snap
T

405 lines
12 KiB
Plaintext
Raw Normal View History

2020-11-26 16:45:25 +01:00
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`t-call dynamic t-call 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
let { isBoundary, zero } = helpers;
const call = app.callTemplate.bind(app);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
2021-10-19 11:00:26 +02:00
ctx[isBoundary] = 1;
const b1 = text(\` owl \`);
2020-11-26 16:45:25 +01:00
ctx[zero] = b1;
const template1 = (ctx['current'].template);
return call(this, template1, ctx, node, key + \`__1\`);
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`t-call dynamic t-call 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div>foo</div>\`);
return function template(ctx, node, key = \\"\\") {
return block1();
}
}"
`;
exports[`t-call dynamic t-call 3`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
return text(\`bar\`);
}
}"
`;
exports[`t-call dynamic t-call: key is propagated 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
2022-05-26 15:09:09 +02:00
const call = app.callTemplate.bind(app);
return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, this, null);
const template1 = (ctx['sub']);
const b3 = call(this, template1, ctx, node, key + \`__2\`);
return multi([b2, b3]);
}
}"
`;
exports[`t-call dynamic t-call: key is propagated 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div block-attribute-0=\\"id\\"/>\`);
return function template(ctx, node, key = \\"\\") {
let attr1 = ctx['id'];
return block1([attr1]);
}
}"
`;
exports[`t-call dynamic t-call: key is propagated 3`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, this, null);
}
}"
`;
exports[`t-call handlers are properly bound through a dynamic t-call 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
const call = app.callTemplate.bind(app);
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const template1 = ('__template__999');
const b2 = call(this, template1, ctx, node, key + \`__1\`);
let txt1 = ctx['counter'];
return block1([txt1], [b2]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call handlers are properly bound through a dynamic t-call 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
return function template(ctx, node, key = \\"\\") {
let hdlr1 = [()=>this.update(), ctx];
return block1([hdlr1]);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call handlers are properly bound through a t-call 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
const callTemplate_1 = app.getTemplate(\`__template__999\`);
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
let txt1 = ctx['counter'];
return block1([txt1], [b2]);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call handlers are properly bound through a t-call 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
return function template(ctx, node, key = \\"\\") {
let hdlr1 = [ctx['update'], ctx];
return block1([hdlr1]);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call handlers with arguments are properly bound through a t-call 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
const callTemplate_1 = app.getTemplate(\`__template__999\`);
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
2020-11-26 16:45:25 +01:00
return block1([], [b2]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call handlers with arguments are properly bound through a t-call 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
2021-12-20 11:19:59 +01:00
const v1 = ctx['a'];
let hdlr1 = [()=>this.update(v1), ctx];
return block1([hdlr1]);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call parent is set within t-call 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
const callTemplate_1 = app.getTemplate(\`__template__999\`);
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
2020-11-26 16:45:25 +01:00
return block1([], [b2]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call parent is set within t-call 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, this, null);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call parent is set within t-call 3`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<span>lucas</span>\`);
return function template(ctx, node, key = \\"\\") {
return block1();
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call parent is set within t-call with no parentNode 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
const callTemplate_1 = app.getTemplate(\`__template__999\`);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
return callTemplate_1.call(this, ctx, node, key + \`__1\`);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call parent is set within t-call with no parentNode 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
2020-11-26 16:45:25 +01:00
2021-12-20 11:19:59 +01:00
return function template(ctx, node, key = \\"\\") {
return comp1({}, key + \`__1\`, node, this, null);
2021-12-20 11:19:59 +01:00
}
}"
`;
exports[`t-call parent is set within t-call with no parentNode 3`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-12-20 11:19:59 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<span>lucas</span>\`);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
2021-12-20 11:19:59 +01:00
return block1();
2020-11-26 16:45:25 +01:00
}
}"
`;
exports[`t-call recursive t-call binding this -- static t-call 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
let { isBoundary, withDefault, setContextValue } = helpers;
const callTemplate_1 = app.getTemplate(\`recursive\`);
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
ctx[isBoundary] = 1
ctx = Object.create(ctx);
ctx[isBoundary] = 1;
setContextValue(ctx, \\"level\\", 0);
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
return block1([], [b2]);
}
}"
`;
exports[`t-call recursive t-call binding this -- static t-call 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
let { isBoundary, withDefault, setContextValue } = helpers;
const callTemplate_1 = app.getTemplate(\`recursive\`);
let block3 = createBlock(\`<div block-handler-0=\\"click.stop\\"><block-text-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
ctx[isBoundary] = 1
let b2;
if (ctx['level']<2) {
let hdlr1 = [\\"stop\\", ctx['onClicked'].bind(this), ctx];
let txt1 = ctx['level'];
const b3 = block3([hdlr1, txt1]);
ctx = Object.create(ctx);
ctx[isBoundary] = 1;
setContextValue(ctx, \\"level\\", ctx['level']+1);
const b4 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
ctx = ctx.__proto__;
b2 = multi([b3, b4]);
}
return multi([b2]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call sub components in two t-calls 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
const callTemplate_1 = app.getTemplate(\`sub\`);
const callTemplate_2 = app.getTemplate(\`sub\`);
2020-11-26 16:45:25 +01:00
let block3 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2,b3;
if (ctx['state'].val===1) {
b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
2020-11-26 16:45:25 +01:00
} else {
const b4 = callTemplate_2.call(this, ctx, node, key + \`__2\`);
2020-11-26 16:45:25 +01:00
b3 = block3([], [b4]);
}
return multi([b2, b3]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call sub components in two t-calls 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
2020-11-26 16:45:25 +01:00
return function template(ctx, node, key = \\"\\") {
return comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call sub components in two t-calls 3`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['props'].val;
return block1([txt1]);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call t-call in t-foreach and children component 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2020-11-26 16:45:25 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2022-05-26 15:09:09 +02:00
let { prepareList, withKey } = helpers;
const callTemplate_1 = app.getTemplate(\`__template__999\`);
2020-11-26 16:45:25 +01:00
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(['a','b','c']);;
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`val\`] = v_block2[i1];
2020-11-26 16:45:25 +01:00
ctx[\`val_first\`] = i1 === 0;
ctx[\`val_last\`] = i1 === v_block2.length - 1;
2020-11-26 16:45:25 +01:00
ctx[\`val_index\`] = i1;
ctx[\`val_value\`] = k_block2[i1];
const key1 = ctx['val'];
c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1);
2020-11-26 16:45:25 +01:00
}
const b2 = list(c_block2);
2020-11-26 16:45:25 +01:00
return block1([], [b2]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`t-call t-call in t-foreach and children component 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-12-20 11:19:59 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
2021-12-20 11:19:59 +01:00
return function template(ctx, node, key = \\"\\") {
return comp1({val: ctx['val']}, key + \`__1\`, node, this, null);
2021-12-20 11:19:59 +01:00
}
}"
`;
exports[`t-call t-call in t-foreach and children component 3`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-12-20 11:19:59 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['props'].val;
return block1([txt1]);
2021-12-20 11:19:59 +01:00
}
}"
`;