File tree 1 file changed +9
-14
lines changed
packages/svelte/src/compiler/phases/1-parse/state 1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -269,33 +269,28 @@ function open(parser) {
269
269
e . expected_identifier ( parser . index ) ;
270
270
}
271
271
272
- let slice_end = parser . index ;
272
+ const params_start = parser . index ;
273
273
274
274
parser . eat ( '(' , true ) ;
275
-
276
275
let parentheses = 1 ;
277
- let params = '' ;
278
276
279
- while ( ! parser . match ( ')' ) || parentheses !== 1 ) {
277
+ while ( parser . index < parser . template . length && ( ! parser . match ( ')' ) || parentheses !== 1 ) ) {
280
278
if ( parser . match ( '(' ) ) parentheses ++ ;
281
279
if ( parser . match ( ')' ) ) parentheses -- ;
282
-
283
- var next_char = parser . read ( / ^ ( .| [ \r \n ] ) / ) ;
284
- if ( next_char == null ) break ; // end of template
285
- params += next_char ;
280
+ parser . index += 1 ;
286
281
}
287
282
288
283
parser . eat ( ')' , true ) ;
289
- parser . eat ( '}' , true ) ;
284
+
285
+ const prelude = parser . template . slice ( 0 , params_start ) . replace ( / \S / g, ' ' ) ;
286
+ const params = parser . template . slice ( params_start , parser . index ) ;
290
287
291
288
let function_expression = /** @type {import('estree').ArrowFunctionExpression } */ (
292
- parse_expression_at (
293
- parser . template . slice ( 0 , slice_end ) . replace ( / \S / g, ' ' ) + `(${ params } ) => {}` ,
294
- parser . ts ,
295
- 0
296
- )
289
+ parse_expression_at ( prelude + `${ params } => {}` , parser . ts , params_start )
297
290
) ;
298
291
292
+ parser . eat ( '}' , true ) ;
293
+
299
294
/** @type {ReturnType<typeof parser.append<import('#compiler').SnippetBlock>> } */
300
295
const block = parser . append ( {
301
296
type : 'SnippetBlock' ,
You can’t perform that action at this time.
0 commit comments