mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] compiler: add better support for "in" and "new" operators
Previously, the support for the "in" operator was iffy, and "new" was not supported at all, "in" would fail when checking if a nested property was in something else, as the leading space would be stripped, and "new" would fail because the following space would be stripped. This commit fixes that by preserving the significant whitespace where necessary.
This commit is contained in:
committed by
Géry Debongnie
parent
4c77132ae2
commit
d917af4614
@@ -135,7 +135,7 @@ describe("expression evaluation", () => {
|
||||
expect(compileExpr("color === 'black'")).toBe("ctx['color']==='black'");
|
||||
expect(compileExpr("'li_'+item")).toBe("'li_'+ctx['item']");
|
||||
expect(compileExpr("state.val > 1")).toBe("ctx['state'].val>1");
|
||||
expect(compileExpr("a in b")).toBe("ctx['a']in ctx['b']");
|
||||
expect(compileExpr("a in b")).toBe("ctx['a'] in ctx['b']");
|
||||
});
|
||||
|
||||
test("boolean operations", () => {
|
||||
@@ -215,4 +215,10 @@ describe("expression evaluation", () => {
|
||||
expect(compileExpr("[a, {b, c},d]")).toBe("[ctx['a'],{b:ctx['b'],c:ctx['c']},ctx['d']]");
|
||||
expect(compileExpr("{a:[b, {c, d: e}]}")).toBe("{a:[ctx['b'],{c:ctx['c'],d:ctx['e']}]}");
|
||||
});
|
||||
|
||||
test("preserving spaces where needed for text operators", () => {
|
||||
expect(compileExpr("new Date()")).toBe("new Date()");
|
||||
expect(compileExpr("a.c in b")).toBe("ctx['a'].c in ctx['b']");
|
||||
expect(compileExpr("typeof val")).toBe("typeof ctx['val']");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user