mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
8f9ad987b9
In odoo/owl#1352 we added support for using t-foreach on Map objects, maps should behave the same as objects where keys are available under the name specified in t-as and values under that same name with the suffix `_value`. Unfortunately, because the code for objects was written in a confusing way (values were stored in a variable named `keys` and vice versa), the implementation for Map was incorrect and keys and values were swapped. This commit fixes that and rewrites the code to be less confusing: keys are extracted from the variables `k_block` and values from `v_block`, which swaps the behaviour, and the code to prepare a list from an object now extracts the keys in `keys` and the values in `values`
698 lines
21 KiB
Plaintext
698 lines
21 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`t-call dynamic t-call 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { isBoundary, zero } = helpers;
|
|
const call = app.callTemplate.bind(app);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1;
|
|
const b1 = text(\` owl \`);
|
|
ctx[zero] = b1;
|
|
const template1 = (ctx['current'].template);
|
|
return call(this, template1, ctx, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call dynamic t-call 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div>foo</div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call dynamic t-call 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(\`bar\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call dynamic t-call with same sub component 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const call = app.callTemplate.bind(app);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = text(ctx['current'].template);
|
|
const template1 = (ctx['current'].template);
|
|
const b3 = call(this, template1, ctx, node, key + \`__1\`);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call dynamic t-call with same sub component 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call dynamic t-call with same sub component 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(\`child\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call dynamic t-call with same sub component 4`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call dynamic t-call: key is propagated 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
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`] = `
|
|
"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`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
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`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
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]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call handlers are properly bound through a dynamic t-call 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const v1 = ctx['this'];
|
|
let hdlr1 = [()=>v1.update(), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call handlers are properly bound through a t-call 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`__template__999\`);
|
|
|
|
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]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call handlers are properly bound through a t-call 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['update'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call handlers with arguments are properly bound through a t-call 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`__template__999\`);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call handlers with arguments are properly bound through a t-call 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const v1 = ctx['this'];
|
|
const v2 = ctx['a'];
|
|
let hdlr1 = [()=>v1.update(v2), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call parent is set within t-call 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`__template__999\`);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call parent is set within t-call 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call parent is set within t-call 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span>lucas</span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call parent is set within t-call with no parentNode 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`__template__999\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call parent is set within t-call with no parentNode 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call parent is set within t-call with no parentNode 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span>lucas</span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call recursive t-call binding this -- static t-call 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
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`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
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(ctx['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]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call sub components in two t-calls 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`sub\`);
|
|
const callTemplate_2 = app.getTemplate(\`sub\`);
|
|
|
|
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\`);
|
|
} else {
|
|
const b4 = callTemplate_2.call(this, ctx, node, key + \`__2\`);
|
|
b3 = block3([], [b4]);
|
|
}
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call sub components in two t-calls 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, [\\"val\\"]);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call sub components in two t-calls 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['props'].val;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call in t-foreach and children component 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
const callTemplate_1 = app.getTemplate(\`__template__999\`);
|
|
|
|
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\`] = k_block2[i1];
|
|
ctx[\`val_first\`] = i1 === 0;
|
|
ctx[\`val_last\`] = i1 === k_block2.length - 1;
|
|
ctx[\`val_index\`] = i1;
|
|
ctx[\`val_value\`] = v_block2[i1];
|
|
const key1 = ctx['val'];
|
|
c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1);
|
|
}
|
|
const b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call in t-foreach and children component 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, [\\"val\\"]);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return comp1({val: ctx['val']}, key + \`__1\`, node, this, null);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call in t-foreach and children component 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['props'].val;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call with t-call-context and subcomponent 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`someTemplate\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let ctx1 = ctx['subctx'];
|
|
return callTemplate_1.call(this, ctx1, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call with t-call-context and subcomponent 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, [\\"name\\"]);
|
|
const comp2 = app.createComponent(\`Child\`, true, false, false, [\\"name\\"]);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = comp1({name: ctx['aab']}, key + \`__1\`, node, this, null);
|
|
const b3 = comp2({name: ctx['lpe']}, key + \`__2\`, node, this, null);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call with t-call-context and subcomponent 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = text(\`child\`);
|
|
const b3 = text(ctx['props'].name);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call with t-call-context and subcomponent, in dev mode 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`someTemplate\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let ctx1 = ctx['subctx'];
|
|
return callTemplate_1.call(this, ctx1, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call with t-call-context and subcomponent, in dev mode 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, [\\"name\\"]);
|
|
const comp2 = app.createComponent(\`Child\`, true, false, false, [\\"name\\"]);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const props1 = {name: ctx['aab']};
|
|
helpers.validateProps(\`Child\`, props1, this);
|
|
const b2 = comp1(props1, key + \`__1\`, node, this, null);
|
|
const props2 = {name: ctx['lpe']};
|
|
helpers.validateProps(\`Child\`, props2, this);
|
|
const b3 = comp2(props2, key + \`__2\`, node, this, null);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call with t-call-context and subcomponent, in dev mode 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = text(\`child\`);
|
|
const b3 = text(ctx['props'].name);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call with t-call-context, simple use 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`someTemplate\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let ctx1 = ctx['subctx'];
|
|
return callTemplate_1.call(this, ctx1, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call with t-call-context, simple use 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = text(ctx['aab']);
|
|
const b3 = text(ctx['lpe']);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call-context: ComponentNode is not looked up in the context 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`someTemplate\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let ctx1 = {method:function(){}};
|
|
return callTemplate_1.call(this, ctx1, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call-context: ComponentNode is not looked up in the context 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { capture, isBoundary, withDefault, setContextValue, markRaw } = helpers;
|
|
const comp1 = app.createComponent(\`Child\`, true, true, false, []);
|
|
|
|
let block2 = createBlock(\`<div block-ref=\\"0\\">outside slot</div>\`);
|
|
let block4 = createBlock(\`<div block-ref=\\"0\\">I'm the default slot</div>\`);
|
|
let block5 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
let ref2 = (el) => this.__owl__.setRef((\`myRef2\`), el);
|
|
const b4 = block4([ref2]);
|
|
setContextValue(ctx, \\"test\\", 3);
|
|
let txt1 = ctx['test'];
|
|
const b5 = block5([txt1]);
|
|
return multi([b4, b5]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let ref1 = (el) => this.__owl__.setRef((\`myRef\`), el);
|
|
const b2 = block2([ref1]);
|
|
const ctx1 = capture(ctx);
|
|
const b6 = comp1({prop: (ctx['method']).bind(this),slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
|
return multi([b2, b6]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call-context: ComponentNode is not looked up in the context 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { callSlot } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return callSlot(ctx, node, key, 'default', false, {});
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call-context: slots don't make component available again when context is captured 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`template\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let ctx1 = {};
|
|
return callTemplate_1.call(this, ctx1, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call-context: slots don't make component available again when context is captured 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { isBoundary, withDefault, setContextValue, capture, markRaw } = helpers;
|
|
const comp1 = app.createComponent(\`Child\`, true, true, false, []);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
return text(ctx['someValue']);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
setContextValue(ctx, \\"dummy\\", 0);
|
|
const ctx1 = capture(ctx);
|
|
const props1 = {slots: markRaw({'default': {__render: slot1.bind(this), __ctx: ctx1}})};
|
|
helpers.validateProps(\`Child\`, props1, this);
|
|
return comp1(props1, key + \`__1\`, node, this, null);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call-context: slots don't make component available again when context is captured 3`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { callSlot } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return callSlot(ctx, node, key, 'default', false, {});
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call-context: this is not available inside t-call-context 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`someTemplate\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let ctx1 = {};
|
|
return callTemplate_1.call(this, ctx1, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-call t-call-context: this is not available inside t-call-context 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(ctx['this']);
|
|
}
|
|
}"
|
|
`;
|