Skip to content

Commit 9fab9c6

Browse files
committed
tweak
1 parent 096ba76 commit 9fab9c6

File tree

1 file changed

+9
-14
lines changed
  • packages/svelte/src/compiler/phases/1-parse/state

1 file changed

+9
-14
lines changed

packages/svelte/src/compiler/phases/1-parse/state/tag.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -269,33 +269,28 @@ function open(parser) {
269269
e.expected_identifier(parser.index);
270270
}
271271

272-
let slice_end = parser.index;
272+
const params_start = parser.index;
273273

274274
parser.eat('(', true);
275-
276275
let parentheses = 1;
277-
let params = '';
278276

279-
while (!parser.match(')') || parentheses !== 1) {
277+
while (parser.index < parser.template.length && (!parser.match(')') || parentheses !== 1)) {
280278
if (parser.match('(')) parentheses++;
281279
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;
286281
}
287282

288283
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);
290287

291288
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)
297290
);
298291

292+
parser.eat('}', true);
293+
299294
/** @type {ReturnType<typeof parser.append<import('#compiler').SnippetBlock>>} */
300295
const block = parser.append({
301296
type: 'SnippetBlock',

0 commit comments

Comments
 (0)