mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
528 lines
17 KiB
Plaintext
528 lines
17 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`t-on can bind event handler 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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['add'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on can bind handlers with arguments 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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 = \\"\\") {
|
|
const v1 = ctx['add'];
|
|
let hdlr1 = [()=>v1(5), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on can bind handlers with empty object 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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 = \\"\\") {
|
|
const v1 = ctx['doSomething'];
|
|
let hdlr1 = [()=>v1({}), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on can bind handlers with empty object (with non empty inner string) 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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 = \\"\\") {
|
|
const v1 = ctx['doSomething'];
|
|
let hdlr1 = [()=>v1({}), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on can bind handlers with empty object (with non empty inner string) 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
|
|
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
|
let block3 = createBlock(\`<li><a block-handler-0=\\"click\\">link</a></li>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
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);
|
|
}
|
|
const b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on can bind handlers with object arguments 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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 = \\"\\") {
|
|
const v1 = ctx['add'];
|
|
let hdlr1 = [()=>v1({val:5}), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on can bind two event handlers 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\" block-handler-1=\\"dblclick\\">Click</button>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['handleClick'], ctx];
|
|
let hdlr2 = [ctx['handleDblClick'], ctx];
|
|
return block1([hdlr1, hdlr2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on handler is bound to proper owner 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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['add'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on handler is bound to proper owner, part 2 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
|
|
let block2 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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 key1 = ctx['value'];
|
|
let hdlr1 = [ctx['add'], ctx];
|
|
c_block1[i1] = withKey(block2([hdlr1]), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on handler is bound to proper owner, part 3 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`sub\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on handler is bound to proper owner, part 3 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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['add'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on handler is bound to proper owner, part 4 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
const callTemplate_1 = app.getTemplate(\`sub\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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];
|
|
ctx[\`value_first\`] = i1 === 0;
|
|
ctx[\`value_last\`] = i1 === v_block1.length - 1;
|
|
ctx[\`value_index\`] = i1;
|
|
ctx[\`value_value\`] = k_block1[i1];
|
|
const key1 = ctx['value'];
|
|
c_block1[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on handler is bound to proper owner, part 4 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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['add'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on receive event in first argument 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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['add'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) basic support for native listener 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div class=\\"myClass\\" block-handler-0=\\"click\\"><button block-handler-1=\\"click\\">Button</button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['divClicked'], ctx];
|
|
let hdlr2 = [ctx['btnClicked'], ctx];
|
|
return block1([hdlr1, hdlr2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on combined with t-esc 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><block-text-1/></button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['onClick'], ctx];
|
|
let txt1 = ctx['text'];
|
|
return block1([hdlr1, txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on combined with t-out 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { safeOutput } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><block-child-0/></button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['onClick'], ctx];
|
|
const b2 = safeOutput(ctx['html']);
|
|
return block1([hdlr1], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on with .capture modifier 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div block-handler-0=\\"click.capture\\"><button block-handler-1=\\"click\\">Button</button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [\\"capture\\", ctx['onCapture'], ctx];
|
|
let hdlr2 = [ctx['doSomething'], ctx];
|
|
return block1([hdlr1, hdlr2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on with empty handler (only modifiers) 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent\\">Button</button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [\\"prevent\\", , ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on with prevent and self modifiers (order matters) 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent.self\\"><span>Button</span></button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [\\"prevent\\",\\"self\\", ctx['onClick'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on with prevent and/or stop modifiers 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent\\">Button 1</button><button block-handler-1=\\"click.stop\\">Button 2</button><button block-handler-2=\\"click.prevent.stop\\">Button 3</button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [\\"prevent\\", ctx['onClickPrevented'], ctx];
|
|
let hdlr2 = [\\"stop\\", ctx['onClickStopped'], ctx];
|
|
let hdlr3 = [\\"prevent\\",\\"stop\\", ctx['onClickPreventedAndStopped'], ctx];
|
|
return block1([hdlr1, hdlr2, hdlr3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-foreach 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<a href=\\"#\\" block-handler-0=\\"click.prevent\\"> Edit <block-text-1/></a>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
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 key1 = ctx['project'];
|
|
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 b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on with self and prevent modifiers (order matters) 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click.self.prevent\\"><span>Button</span></button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [\\"self\\",\\"prevent\\", ctx['onClick'], ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (native listener) t-on with self modifier 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><span>Button</span></button><button block-handler-1=\\"click.self\\"><span>Button</span></button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [ctx['onClick'], ctx];
|
|
let hdlr2 = [\\"self\\", ctx['onClickSelf'], ctx];
|
|
return block1([hdlr1, hdlr2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on modifiers (synthetic listener) basic support for synthetic 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div block-handler-0=\\"click.synthetic\\"><button block-handler-1=\\"click.synthetic\\">Button</button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let hdlr1 = [\\"synthetic\\", ctx['divClicked'], ctx];
|
|
let hdlr2 = [\\"synthetic\\", ctx['btnClicked'], ctx];
|
|
return block1([hdlr1, hdlr2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on with inline statement (function call) 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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 = \\"\\") {
|
|
const v1 = ctx['state'];
|
|
let hdlr1 = [()=>v1.incrementCounter(2), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on with inline statement 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
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 = \\"\\") {
|
|
const v1 = ctx['state'];
|
|
let hdlr1 = [()=>v1.counter++, ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on with inline statement, part 2 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Toggle</button>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const v1 = ctx['state'];
|
|
let hdlr1 = [()=>v1.flag=!v1.flag, ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on with inline statement, part 3 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Toggle</button>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const v1 = ctx['state'];
|
|
const v2 = ctx['someFunction'];
|
|
let hdlr1 = [()=>v1.n=v2(3), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-on t-on with t-call 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`sub\`);
|
|
|
|
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-on t-on with 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-on t-on, with arguments and t-call 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const callTemplate_1 = app.getTemplate(\`sub\`);
|
|
|
|
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-on t-on, with arguments and 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['value'];
|
|
let hdlr1 = [()=>this.update(v1), ctx];
|
|
return block1([hdlr1]);
|
|
}
|
|
}"
|
|
`;
|