mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
2068196377
Before this commit, generated template functions were not using strict mode. This may be a bad idea, since strict mode could be more performant in some cases.
168 lines
5.1 KiB
Plaintext
168 lines
5.1 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`event handling Invalid handler throws an error 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">click</button>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['dosomething'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`event handling handler is not called if component is destroyed 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span block-handler-0=\\"click\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['click'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`event handling handler receive the event as argument 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
|
|
|
|
let block1 = createBlock(\`<span block-handler-0=\\"click\\"><block-child-0/><block-text-1/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['inc'], ctx];
|
|
const b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
let txt1 = ctx['state'].value;
|
|
return block1([hdlr1, txt1], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`event handling handler receive the event as argument 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div>simple vnode</div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`event handling input blur event is not called if component is destroyed 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><textarea/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2;
|
|
if (ctx['state'].cond) {
|
|
b2 = comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`event handling input blur event is not called if component is destroyed 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<input block-handler-0=\\"blur\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['blur'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`event handling objects from scope are properly captured by t-on 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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 key1 = ctx['item'];
|
|
const v1 = ctx['onClick'];
|
|
const v2 = ctx['item'];
|
|
let hdlr1 = [_ev=>v1(v2.val,_ev), ctx];
|
|
c_block2[i1] = withKey(block3([hdlr1]), key1);
|
|
}
|
|
const b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`event handling support for callable expression in event handler 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><input type=\\"text\\" block-handler-1=\\"input\\"/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['state'].value;
|
|
let hdlr1 = [ctx['obj'].onInput, ctx];
|
|
return block1([txt1, hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`event handling t-on with handler bound to dynamic argument on a t-foreach 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
\\"use strict\\";
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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 key1 = ctx['item'];
|
|
const v1 = ctx['onClick'];
|
|
const v2 = ctx['item'];
|
|
let hdlr1 = [_ev=>v1(v2,_ev), ctx];
|
|
c_block2[i1] = withKey(block3([hdlr1]), key1);
|
|
}
|
|
const b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|