mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] compiler: handle t-set as functions
This commit is contained in:
committed by
Mathieu Duckerts-Antoine
parent
f014b1a33e
commit
5b1132f01a
@@ -114,16 +114,19 @@ exports[`t-esc t-esc is escaped 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault } = helpers;
|
||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||
let block2 = createBlock(\`<p>escaped</p>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
return block2();
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
let b2 = block2();
|
||||
ctx[\`var\`] = b2;
|
||||
ctx[\`var\`] = new LazyValue(value1, ctx, node);
|
||||
let txt1 = ctx['var'];
|
||||
return block1([txt1]);
|
||||
}
|
||||
|
||||
@@ -134,16 +134,19 @@ exports[`t-out t-out bdom 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, safeOutput } = helpers;
|
||||
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><span><block-child-0/></span></div>\`);
|
||||
let block2 = createBlock(\`<ol>set</ol>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
return block2();
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
let b2 = block2();
|
||||
ctx[\`var\`] = b2;
|
||||
ctx[\`var\`] = new LazyValue(value1, ctx, node);
|
||||
let b3 = safeOutput(ctx['var']);
|
||||
return block1([], [b3]);
|
||||
}
|
||||
@@ -277,19 +280,22 @@ exports[`t-out t-out switch markup on bdom 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, safeOutput } = helpers;
|
||||
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||
let block2 = createBlock(\`<ol>set</ol>\`);
|
||||
let block3 = createBlock(\`<span><block-child-0/></span>\`);
|
||||
let block5 = createBlock(\`<span><block-child-0/></span>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
return block2();
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
let b3,b5;
|
||||
let b2 = block2();
|
||||
ctx[\`bdom\`] = b2;
|
||||
ctx[\`bdom\`] = new LazyValue(value1, ctx, node);
|
||||
if (ctx['hasBdom']) {
|
||||
let b4 = safeOutput(ctx['bdom']);
|
||||
b3 = block3([], [b4]);
|
||||
|
||||
@@ -106,15 +106,18 @@ exports[`t-set set from body lookup 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault } = helpers;
|
||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
return text(ctx['value']);
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
let b2 = text(ctx['value']);
|
||||
ctx[\`stuff\`] = b2;
|
||||
ctx[\`stuff\`] = new LazyValue(value1, ctx, node);
|
||||
let txt1 = ctx['stuff'];
|
||||
return block1([txt1]);
|
||||
}
|
||||
@@ -164,18 +167,21 @@ exports[`t-set t-set body is evaluated immediately 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue, safeOutput } = helpers;
|
||||
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
let txt1 = ctx['v1'];
|
||||
return block2([txt1]);
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"v1\\", 'before');
|
||||
let txt1 = ctx['v1'];
|
||||
let b2 = block2([txt1]);
|
||||
ctx[\`v2\`] = b2;
|
||||
ctx[\`v2\`] = new LazyValue(value1, ctx, node);
|
||||
setContextValue(ctx, \\"v1\\", 'after');
|
||||
let b3 = safeOutput(ctx['v2']);
|
||||
return block1([], [b3]);
|
||||
@@ -427,17 +433,20 @@ exports[`t-set t-set with content and sub t-esc 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault } = helpers;
|
||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
let b3 = text(ctx['beep']);
|
||||
let b4 = text(\` boop\`);
|
||||
return multi([b3, b4]);
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
let b3 = text(ctx['beep']);
|
||||
let b4 = text(\` boop\`);
|
||||
let b2 = multi([b3, b4]);
|
||||
ctx[\`setvar\`] = b2;
|
||||
ctx[\`setvar\`] = new LazyValue(value1, ctx, node);
|
||||
let txt1 = ctx['setvar'];
|
||||
return block1([txt1]);
|
||||
}
|
||||
@@ -448,19 +457,22 @@ exports[`t-set t-set with t-value (falsy) and body 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue, safeOutput } = helpers;
|
||||
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
let txt1 = ctx['v1'];
|
||||
return block2([txt1]);
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"v3\\", false);
|
||||
setContextValue(ctx, \\"v1\\", 'before');
|
||||
let txt1 = ctx['v1'];
|
||||
let b2 = block2([txt1]);
|
||||
ctx[\`v2\`] = withDefault(ctx['v3'], b2);
|
||||
ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, node));
|
||||
setContextValue(ctx, \\"v1\\", 'after');
|
||||
setContextValue(ctx, \\"v3\\", true);
|
||||
let b3 = safeOutput(ctx['v2']);
|
||||
@@ -473,19 +485,22 @@ exports[`t-set t-set with t-value (truthy) and body 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue, safeOutput } = helpers;
|
||||
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
let txt1 = ctx['v1'];
|
||||
return block2([txt1]);
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"v3\\", 'Truthy');
|
||||
setContextValue(ctx, \\"v1\\", 'before');
|
||||
let txt1 = ctx['v1'];
|
||||
let b2 = block2([txt1]);
|
||||
ctx[\`v2\`] = withDefault(ctx['v3'], b2);
|
||||
ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, node));
|
||||
setContextValue(ctx, \\"v1\\", 'after');
|
||||
setContextValue(ctx, \\"v3\\", false);
|
||||
let b3 = safeOutput(ctx['v2']);
|
||||
@@ -563,16 +578,19 @@ exports[`t-set value priority (with non text body 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault } = helpers;
|
||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||
let block2 = createBlock(\`<span>2</span>\`);
|
||||
|
||||
function value1(ctx, node, key = \\"\\") {
|
||||
return block2();
|
||||
}
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
let b2 = block2();
|
||||
ctx[\`value\`] = withDefault(1, b2);
|
||||
ctx[\`value\`] = withDefault(1, new LazyValue(value1, ctx, node));
|
||||
let txt1 = ctx['value'];
|
||||
return block1([txt1]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user