[REF] move component function to app, improve some code

This commit is contained in:
Géry Debongnie
2022-06-08 11:09:39 +02:00
committed by Sam Degueldre
parent 51538c2fea
commit 0e6059467f
53 changed files with 2522 additions and 1975 deletions
@@ -3,12 +3,13 @@
exports[`t-props basic use 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = component(\`Child\`, Object.assign({}, ctx['some'].obj), key + \`__1\`, node, ctx);
const b2 = comp1(Object.assign({}, ctx['some'].obj), key + \`__1\`, node, ctx, null);
return block1([], [b2]);
}
}"
@@ -17,7 +18,7 @@ exports[`t-props basic use 1`] = `
exports[`t-props basic use 2`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<span><block-text-0/></span>\`);
@@ -31,10 +32,11 @@ exports[`t-props basic use 2`] = `
exports[`t-props child receives a copy of the t-props object, not the original 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, true);
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, Object.assign({}, ctx['childProps']), key + \`__1\`, node, ctx);
return comp1(Object.assign({}, ctx['childProps']), key + \`__1\`, node, ctx, null);
}
}"
`;
@@ -42,7 +44,7 @@ exports[`t-props child receives a copy of the t-props object, not the original 1
exports[`t-props child receives a copy of the t-props object, not the original 2`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div/>\`);
@@ -55,12 +57,13 @@ exports[`t-props child receives a copy of the t-props object, not the original 2
exports[`t-props t-props and other props 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Comp\`, true, false, true);
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = component(\`Comp\`, Object.assign({}, ctx['state1'], {a: ctx['a']}), key + \`__1\`, node, ctx);
const b2 = comp1(Object.assign({}, ctx['state1'], {a: ctx['a']}), key + \`__1\`, node, ctx, null);
return block1([], [b2]);
}
}"
@@ -69,7 +72,7 @@ exports[`t-props t-props and other props 1`] = `
exports[`t-props t-props and other props 2`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
@@ -84,12 +87,13 @@ exports[`t-props t-props and other props 2`] = `
exports[`t-props t-props only 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Comp\`, true, false, true);
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = component(\`Comp\`, Object.assign({}, ctx['state']), key + \`__1\`, node, ctx);
const b2 = comp1(Object.assign({}, ctx['state']), key + \`__1\`, node, ctx, null);
return block1([], [b2]);
}
}"
@@ -98,7 +102,7 @@ exports[`t-props t-props only 1`] = `
exports[`t-props t-props only 2`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div><block-text-0/></div>\`);
@@ -112,12 +116,13 @@ exports[`t-props t-props only 2`] = `
exports[`t-props t-props with props 1`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, true);
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = component(\`Child\`, Object.assign({}, ctx['childProps'], {a: 1,b: 2}), key + \`__1\`, node, ctx);
const b2 = comp1(Object.assign({}, ctx['childProps'], {a: 1,b: 2}), key + \`__1\`, node, ctx, null);
return block1([], [b2]);
}
}"
@@ -126,7 +131,7 @@ exports[`t-props t-props with props 1`] = `
exports[`t-props t-props with props 2`] = `
"function anonymous(app, bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let block1 = createBlock(\`<div/>\`);