[FIX] components: only call handlers if component is mounted

This commit is contained in:
Géry Debongnie
2022-01-17 14:13:32 +01:00
committed by Aaron Bohy
parent 7711733a23
commit 42a140a8e3
4 changed files with 114 additions and 8 deletions
@@ -1,5 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`event handling handler is not called if component is destroyed 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, 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(bdom, helpers
) {
@@ -29,6 +43,37 @@ exports[`event handling handler receive the event as argument 2`] = `
}"
`;
exports[`event handling input blur event is not called if component is destroyed 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let block1 = createBlock(\`<div><block-child-0/><textarea/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2;
if (ctx['state'].cond) {
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
}
return block1([], [b2]);
}
}"
`;
exports[`event handling input blur event is not called if component is destroyed 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, 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(bdom, helpers
) {