mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[REF] move component function to app, improve some code
This commit is contained in:
committed by
Sam Degueldre
parent
51538c2fea
commit
0e6059467f
@@ -3,10 +3,11 @@
|
||||
exports[`basics 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, false);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return component(\`Child\`, {p: 1}, key + \`__1\`, node, ctx);
|
||||
return comp1({p: 1}, key + \`__1\`, node, ctx, null);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
@@ -14,7 +15,7 @@ exports[`basics basic use 1`] = `
|
||||
exports[`basics 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>child<block-text-0/></span>\`);
|
||||
|
||||
@@ -28,15 +29,17 @@ exports[`basics basic use 2`] = `
|
||||
exports[`basics can select a sub widget 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, false);
|
||||
const comp2 = app.createComponent(\`OtherChild\`, true, false, false);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2,b3;
|
||||
if (ctx['env'].options.flag) {
|
||||
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||
b2 = comp1({}, key + \`__1\`, node, ctx, null);
|
||||
}
|
||||
if (!ctx['env'].options.flag) {
|
||||
b3 = component(\`OtherChild\`, {}, key + \`__2\`, node, ctx);
|
||||
b3 = comp2({}, key + \`__2\`, node, ctx, null);
|
||||
}
|
||||
return multi([b2, b3]);
|
||||
}
|
||||
@@ -46,7 +49,7 @@ exports[`basics can select a sub widget 1`] = `
|
||||
exports[`basics can select a sub widget 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>CHILD 1</span>\`);
|
||||
|
||||
@@ -59,7 +62,7 @@ exports[`basics can select a sub widget 2`] = `
|
||||
exports[`basics can select a sub widget 3`] = `
|
||||
"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>CHILD 2</div>\`);
|
||||
|
||||
@@ -72,15 +75,17 @@ exports[`basics can select a sub widget 3`] = `
|
||||
exports[`basics can select a sub widget, part 2 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, false);
|
||||
const comp2 = app.createComponent(\`OtherChild\`, true, false, false);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2,b3;
|
||||
if (ctx['state'].flag) {
|
||||
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||
b2 = comp1({}, key + \`__1\`, node, ctx, null);
|
||||
}
|
||||
if (!ctx['state'].flag) {
|
||||
b3 = component(\`OtherChild\`, {}, key + \`__2\`, node, ctx);
|
||||
b3 = comp2({}, key + \`__2\`, node, ctx, null);
|
||||
}
|
||||
return multi([b2, b3]);
|
||||
}
|
||||
@@ -90,7 +95,7 @@ exports[`basics can select a sub widget, part 2 1`] = `
|
||||
exports[`basics can select a sub widget, part 2 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>CHILD 1</span>\`);
|
||||
|
||||
@@ -103,7 +108,7 @@ exports[`basics can select a sub widget, part 2 2`] = `
|
||||
exports[`basics can select a sub widget, part 2 3`] = `
|
||||
"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>CHILD 2</div>\`);
|
||||
|
||||
@@ -116,10 +121,11 @@ exports[`basics can select a sub widget, part 2 3`] = `
|
||||
exports[`basics sub widget is interactive 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, false);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return component(\`Child\`, {p: 1}, key + \`__1\`, node, ctx);
|
||||
return comp1({p: 1}, key + \`__1\`, node, ctx, null);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
@@ -127,7 +133,7 @@ exports[`basics sub widget is interactive 1`] = `
|
||||
exports[`basics sub widget is interactive 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><button block-handler-0=\\"click\\">click</button>child<block-text-1/></span>\`);
|
||||
|
||||
@@ -142,12 +148,13 @@ exports[`basics sub widget is interactive 2`] = `
|
||||
exports[`basics top level sub widget with a parent 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(\`ComponentB\`, true, false, false);
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
const b2 = component(\`ComponentB\`, {}, key + \`__1\`, node, ctx);
|
||||
const b2 = comp1({}, key + \`__1\`, node, ctx, null);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
@@ -156,10 +163,11 @@ exports[`basics top level sub widget with a parent 1`] = `
|
||||
exports[`basics top level sub widget with a parent 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;
|
||||
const comp1 = app.createComponent(\`ComponentC\`, true, false, false);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return component(\`ComponentC\`, {}, key + \`__1\`, node, ctx);
|
||||
return comp1({}, key + \`__1\`, node, ctx, null);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
@@ -167,7 +175,7 @@ exports[`basics top level sub widget with a parent 2`] = `
|
||||
exports[`basics top level sub widget with a parent 3`] = `
|
||||
"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>Hello</span>\`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user