mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
521111644c
Several directives (t-key, t-log, t-translation, …) are represented by wrapper ASTs that contain another AST or null. Because these wrappers don't share the same type as their children, various AST type checks were broken. This commit addresses those issues by: - Commuting Translation / TranslationContext and Multi ASTs so that Multi children are spread as expected (see parseChildren). - Parsing the t-key directive before t-esc / t-out (in line with https://github.com/odoo/owl/pull/1685). - Ensuring wrappers around TSet ASTs are recognized as having no representation, so compileMulti properly discards children equivalent to TSet.
121 lines
3.4 KiB
Plaintext
121 lines
3.4 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`t-key can use t-key directive on a node 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const tKey_1 = ctx['beer'].id;
|
|
let txt1 = ctx['beer'].name;
|
|
return toggler(tKey_1, block1([txt1]));
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-key can use t-key directive on a node 2 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const tKey_1 = ctx['beer'].id;
|
|
let txt1 = ctx['beer'].name;
|
|
return toggler(tKey_1, block1([txt1]));
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-key can use t-key directive on a node as a function 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const tKey_1 = ctx['getKey'](ctx['beer']);
|
|
let txt1 = ctx['beer'].name;
|
|
return toggler(tKey_1, block1([txt1]));
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-key t-key directive in a list 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, withKey } = helpers;
|
|
|
|
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
|
let block3 = createBlock(\`<li><block-text-0/></li>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['beers']);;
|
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
|
ctx[\`beer\`] = k_block2[i1];
|
|
const key1 = ctx['beer'].id;
|
|
let txt1 = ctx['beer'].name;
|
|
c_block2[i1] = withKey(block3([txt1]), key1);
|
|
}
|
|
const b2 = list(c_block2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-key t-key on sub dom node pushes a child block in its parent 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
|
let block2 = createBlock(\`<span/>\`);
|
|
let block3 = createBlock(\`<div><h1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2, b3;
|
|
if (ctx['hasSpan']) {
|
|
b2 = block2();
|
|
}
|
|
const tKey_1 = ctx['key'];
|
|
b3 = toggler(tKey_1, block3());
|
|
return block1([], [b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-key t-key on sub dom node pushes a child block in its parent 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><h1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const tKey_1 = ctx['key'];
|
|
return toggler(tKey_1, block1());
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-key t-key: interaction with t-esc 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<p><block-text-0/></p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const tKey_1 = ctx['key'];
|
|
let txt1 = ctx['text'];
|
|
return toggler(tKey_1, block1([txt1]));
|
|
}
|
|
}"
|
|
`;
|