diff --git a/src/compiler/inline_expressions.ts b/src/compiler/inline_expressions.ts index af531df00..e67b769ea 100644 --- a/src/compiler/inline_expressions.ts +++ b/src/compiler/inline_expressions.ts @@ -268,7 +268,7 @@ export function compileExprToArray(expr: string): Token[] { const localVars = new Set(); const tokens = tokenize(expr); let i = 0; - let stack = []; // to track last opening [ or { + let stack = []; // to track last opening (, [ or { while (i < tokens.length) { let token = tokens[i]; @@ -279,10 +279,12 @@ export function compileExprToArray(expr: string): Token[] { switch (token.type) { case "LEFT_BRACE": case "LEFT_BRACKET": + case "LEFT_PAREN": stack.push(token.type); break; case "RIGHT_BRACE": case "RIGHT_BRACKET": + case "RIGHT_PAREN": stack.pop(); } diff --git a/tests/compiler/inline_expressions.test.ts b/tests/compiler/inline_expressions.test.ts index b375da9f1..ab00a2b0f 100644 --- a/tests/compiler/inline_expressions.test.ts +++ b/tests/compiler/inline_expressions.test.ts @@ -174,6 +174,9 @@ describe("expression evaluation", () => { expect(compileExpr("list.data.map((data) => data)")).toBe( "ctx['list'].data.map((_data)=>_data)" ); + expect(compileExpr("(ev) => { myFunc(v1, v2, ev.target.value); }")).toBe( + "(_ev)=>{ctx['myFunc'](ctx['v1'],ctx['v2'],_ev.target.value);}" + ); }); test.skip("arrow functions: not yet supported", () => { // e is added to localvars in inline_expression but not removed after the arrow func body