mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
8f9ad987b9
In odoo/owl#1352 we added support for using t-foreach on Map objects, maps should behave the same as objects where keys are available under the name specified in t-as and values under that same name with the suffix `_value`. Unfortunately, because the code for objects was written in a confusing way (values were stored in a variable named `keys` and vice versa), the implementation for Map was incorrect and keys and values were swapped. This commit fixes that and rewrites the code to be less confusing: keys are extracted from the variables `k_block` and values from `v_block`, which swaps the behaviour, and the code to prepare a list from an object now extracts the keys in `keys` and the values in `values`
40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`components in t-out simple list 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { prepareList, isBoundary, withDefault, LazyValue, safeOutput, withKey } = helpers;
|
|
const comp1 = app.createComponent(\`Child\`, true, false, false, []);
|
|
|
|
function value1(ctx, node, key = \\"\\") {
|
|
return comp1({}, key + \`__1\`, node, this, null);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[isBoundary] = 1
|
|
ctx = Object.create(ctx);
|
|
const [k_block1, v_block1, l_block1, c_block1] = prepareList([1,2]);;
|
|
for (let i1 = 0; i1 < l_block1; i1++) {
|
|
ctx[\`n\`] = k_block1[i1];
|
|
const key1 = ctx['n'];
|
|
ctx[\`blabla\`] = new LazyValue(value1, ctx, this, node, key1);
|
|
c_block1[i1] = withKey(safeOutput(ctx['blabla']), key1);
|
|
}
|
|
return list(c_block1);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`components in t-out simple list 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return text(\`child\`);
|
|
}
|
|
}"
|
|
`;
|