File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ export function args(func) {
132132 let inDoubleQuote = false ;
133133 let parenthesisCount = 0 ;
134134 let bracketCount = 0 ;
135+ let curlyCount = 0 ;
135136
136137 for ( let idx = 0 ; idx < func . length ; idx ++ ) {
137138 const c = func . charAt ( idx ) ;
@@ -145,6 +146,10 @@ export function args(func) {
145146 parenthesisCount ++ ;
146147 } else if ( c === ")" ) {
147148 parenthesisCount -- ;
149+ } else if ( c === "{" ) {
150+ curlyCount ++ ;
151+ } else if ( c === "}" ) {
152+ curlyCount -- ;
148153 } else if ( c === "'" ) {
149154 inSingleQuote = ! inSingleQuote ;
150155 } else if ( c === "\"" ) {
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ test("two args with array", (t) => {
2424 t . is ( functionArgs [ 1 ] , "[1, 2]" ) ;
2525} ) ;
2626
27+ test ( "two args with object" , ( t ) => {
28+ const functionArgs = args ( "test($event.target.value, {\"1\": 2})" ) ;
29+
30+ t . is ( functionArgs . length , 2 ) ;
31+ t . is ( functionArgs [ 0 ] , "$event.target.value" ) ;
32+ t . is ( functionArgs [ 1 ] , "{\"1\": 2}" ) ;
33+ } ) ;
34+
2735test ( "two args with comma in double quotes" , ( t ) => {
2836 const functionArgs = args ( "test($event.target.value, \"1,2\")" ) ;
2937
You can’t perform that action at this time.
0 commit comments