mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: properly handle lists in inline expressions
Before this commit, Owl inline expressions with a list with multiple
elements such as [a,b,c] was transformed into
[scope['a'], b: scope['b'], scope['c']]
instead of
[scope['a'], scope['b'], scope['c']]
This is due to a previous commit adding support for short object
descriptions such as {a,b}.
To fix this means that we have to keep track of the current group type
for the expression, which is done by using a stack.
This commit is contained in:
@@ -207,6 +207,17 @@ describe("expression evaluation", () => {
|
||||
expect(compileExpr("{a,b:3,c}", {})).toBe("{a:scope['a'],b:3,c:scope['c']}");
|
||||
});
|
||||
|
||||
test("works with short object description and lists ", () => {
|
||||
expect(compileExpr("[a, b]", {})).toBe("[scope['a'],scope['b']]");
|
||||
expect(compileExpr("[a, b, c]", {})).toBe("[scope['a'],scope['b'],scope['c']]");
|
||||
expect(compileExpr("[a, {b, c},d]", {})).toBe(
|
||||
"[scope['a'],{b:scope['b'],c:scope['c']},scope['d']]"
|
||||
);
|
||||
expect(compileExpr("{a:[b, {c, d: e}]}", {})).toBe(
|
||||
"{a:[scope['b'],{c:scope['c'],d:scope['e']}]}"
|
||||
);
|
||||
});
|
||||
|
||||
test("template strings", () => {
|
||||
expect(compileExpr("`hey`", {})).toBe("`hey`");
|
||||
expect(compileExpr("`hey ${you}`", {})).toBe("`hey ${scope['you']}`");
|
||||
|
||||
Reference in New Issue
Block a user