2020-11-26 16:45:25 +01:00
|
|
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
|
|
2022-01-20 14:52:47 +01:00
|
|
|
exports[`event handling Invalid handler throws an error 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2022-01-20 14:52:47 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2022-01-20 14:52:47 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">click</button>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
let hdlr1 = [ctx['dosomething'], ctx];
|
|
|
|
|
return block1([hdlr1]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2022-01-17 14:13:32 +01:00
|
|
|
exports[`event handling handler is not called if component is destroyed 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2022-01-17 14:13:32 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2022-01-17 14:13:32 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<span block-handler-0=\\"click\\"/>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
let hdlr1 = [ctx['click'], ctx];
|
|
|
|
|
return block1([hdlr1]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
exports[`event handling handler receive the event as argument 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2023-02-27 07:57:33 +01:00
|
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
2020-11-26 16:45:25 +01:00
|
|
|
|
2021-12-20 11:19:59 +01:00
|
|
|
let block1 = createBlock(\`<span block-handler-0=\\"click\\"><block-child-0/><block-text-1/></span>\`);
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
2021-12-22 11:33:12 +01:00
|
|
|
let hdlr1 = [ctx['inc'], ctx];
|
2022-06-22 15:39:31 +02:00
|
|
|
const b2 = comp1({}, key + \`__1\`, node, this, null);
|
2021-12-22 12:33:17 +01:00
|
|
|
let txt1 = ctx['state'].value;
|
|
|
|
|
return block1([hdlr1, txt1], [b2]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`event handling handler receive the event as argument 2`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-10-26 09:46:49 +02:00
|
|
|
|
2021-12-20 11:19:59 +01:00
|
|
|
let block1 = createBlock(\`<div>simple vnode</div>\`);
|
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
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2022-09-06 11:56:58 +02:00
|
|
|
exports[`event handling handler works when app is mounted in an iframe 1`] = `
|
|
|
|
|
"function anonymous(app, bdom, helpers
|
|
|
|
|
) {
|
|
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<span block-handler-0=\\"click\\">click me</span>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
let hdlr1 = [ctx['inc'], ctx];
|
|
|
|
|
return block1([hdlr1]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2022-01-17 14:13:32 +01:00
|
|
|
exports[`event handling input blur event is not called if component is destroyed 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2022-01-17 14:13:32 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2023-02-27 07:57:33 +01:00
|
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
2022-01-17 14:13:32 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><textarea/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
let b2;
|
|
|
|
|
if (ctx['state'].cond) {
|
2022-06-22 15:39:31 +02:00
|
|
|
b2 = comp1({}, key + \`__1\`, node, this, null);
|
2022-01-17 14:13:32 +01:00
|
|
|
}
|
|
|
|
|
return block1([], [b2]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
exports[`event handling input blur event is not called if component is destroyed 2`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2022-01-17 14:13:32 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2022-01-17 14:13:32 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<input block-handler-0=\\"blur\\"/>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
|
|
|
let hdlr1 = [ctx['blur'], ctx];
|
|
|
|
|
return block1([hdlr1]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2021-11-22 12:04:58 +01:00
|
|
|
exports[`event handling objects from scope are properly captured by t-on 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-11-22 12:04:58 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { prepareList, withKey } = helpers;
|
2021-11-22 12:04:58 +01:00
|
|
|
|
|
|
|
|
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);
|
2022-03-06 10:27:07 +01:00
|
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['items']);;
|
2021-11-22 12:04:58 +01:00
|
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
2023-08-02 07:55:58 +02:00
|
|
|
ctx[\`item\`] = k_block2[i1];
|
2022-03-06 10:27:07 +01:00
|
|
|
const key1 = ctx['item'];
|
2021-11-22 12:04:58 +01:00
|
|
|
const v1 = ctx['onClick'];
|
|
|
|
|
const v2 = ctx['item'];
|
2022-01-27 10:42:26 +01:00
|
|
|
let hdlr1 = [_ev=>v1(v2.val,_ev), ctx];
|
2021-12-22 11:33:12 +01:00
|
|
|
c_block2[i1] = withKey(block3([hdlr1]), key1);
|
2021-11-22 12:04:58 +01:00
|
|
|
}
|
2022-03-06 10:27:07 +01:00
|
|
|
const b2 = list(c_block2);
|
2021-11-22 12:04:58 +01:00
|
|
|
return block1([], [b2]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
|
|
|
|
|
2020-11-26 16:45:25 +01:00
|
|
|
exports[`event handling support for callable expression in event handler 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2020-11-26 16:45:25 +01:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2020-11-26 16:45:25 +01:00
|
|
|
|
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><input type=\\"text\\" block-handler-1=\\"input\\"/></div>\`);
|
|
|
|
|
|
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
2021-12-22 11:33:12 +01:00
|
|
|
let txt1 = ctx['state'].value;
|
2021-12-22 12:33:17 +01:00
|
|
|
let hdlr1 = [ctx['obj'].onInput, ctx];
|
|
|
|
|
return block1([txt1, hdlr1]);
|
2020-11-26 16:45:25 +01:00
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|
2021-10-21 10:13:08 +02:00
|
|
|
|
|
|
|
|
exports[`event handling t-on with handler bound to dynamic argument on a t-foreach 1`] = `
|
2022-05-26 15:09:09 +02:00
|
|
|
"function anonymous(app, bdom, helpers
|
2021-10-21 10:13:08 +02:00
|
|
|
) {
|
2022-06-08 11:09:39 +02:00
|
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
2021-12-01 17:03:53 +01:00
|
|
|
let { prepareList, withKey } = helpers;
|
2021-10-21 10:13:08 +02:00
|
|
|
|
|
|
|
|
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);
|
2022-03-06 10:27:07 +01:00
|
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['items']);;
|
2021-10-21 10:13:08 +02:00
|
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
2023-08-02 07:55:58 +02:00
|
|
|
ctx[\`item\`] = k_block2[i1];
|
2022-03-06 10:27:07 +01:00
|
|
|
const key1 = ctx['item'];
|
2021-11-12 12:56:07 +01:00
|
|
|
const v1 = ctx['onClick'];
|
|
|
|
|
const v2 = ctx['item'];
|
2022-01-27 10:42:26 +01:00
|
|
|
let hdlr1 = [_ev=>v1(v2,_ev), ctx];
|
2021-12-22 11:33:12 +01:00
|
|
|
c_block2[i1] = withKey(block3([hdlr1]), key1);
|
2021-10-21 10:13:08 +02:00
|
|
|
}
|
2022-03-06 10:27:07 +01:00
|
|
|
const b2 = list(c_block2);
|
2021-10-21 10:13:08 +02:00
|
|
|
return block1([], [b2]);
|
|
|
|
|
}
|
|
|
|
|
}"
|
|
|
|
|
`;
|