mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] compiler: fix swapped key/value using t-foreach on Map
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`
This commit is contained in:
committed by
aab-odoo
parent
6050827689
commit
8f9ad987b9
@@ -11,7 +11,7 @@ exports[`.alike suffix in a list 1`] = `
|
||||
ctx = Object.create(ctx);
|
||||
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['state'].elems);;
|
||||
for (let i1 = 0; i1 < l_block1; i1++) {
|
||||
ctx[\`elem\`] = v_block1[i1];
|
||||
ctx[\`elem\`] = k_block1[i1];
|
||||
const key1 = ctx['elem'].id;
|
||||
const v1 = ctx['this'];
|
||||
const v2 = ctx['elem'];
|
||||
@@ -106,7 +106,7 @@ exports[`basics arrow functions as prop correctly capture their scope 1`] = `
|
||||
ctx = Object.create(ctx);
|
||||
const [k_block1, v_block1, l_block1, c_block1] = prepareList(ctx['items']);;
|
||||
for (let i1 = 0; i1 < l_block1; i1++) {
|
||||
ctx[\`item\`] = v_block1[i1];
|
||||
ctx[\`item\`] = k_block1[i1];
|
||||
const key1 = ctx['item'].val;
|
||||
const v1 = ctx['onClick'];
|
||||
const v2 = ctx['item'];
|
||||
|
||||
Reference in New Issue
Block a user