@@ -1290,35 +1290,23 @@ const common_visitors = {
1290
1290
}
1291
1291
} ,
1292
1292
CallExpression ( node , context ) {
1293
- const { expression } = context . state ;
1293
+ const { expression, render_tag } = context . state ;
1294
1294
if (
1295
1295
( expression ?. type === 'ExpressionTag' || expression ?. type === 'SpreadAttribute' ) &&
1296
1296
! is_known_safe_call ( node , context )
1297
1297
) {
1298
1298
expression . metadata . contains_call_expression = true ;
1299
1299
}
1300
1300
1301
- if ( context . state . ast_type === 'template' ) {
1302
- // Find out if this is a call expression inside a render tag argument
1303
- let i = - 1 ;
1304
- let parent = context . path . at ( i ) ;
1305
-
1306
- while ( parent && parent . type !== 'RenderTag' ) {
1307
- i -= 1 ;
1308
- parent = context . path . at ( i ) ;
1309
- }
1310
-
1311
- if ( parent ) {
1312
- const arg_path_idx = i + ( parent . expression . type === 'CallExpression' ? 2 : 3 ) ;
1301
+ if ( render_tag ) {
1302
+ // Find out which of the render tag arguments contains this call expression
1303
+ const arg_idx = unwrap_optional ( render_tag . expression ) . arguments . findIndex (
1304
+ ( arg ) => arg === node || context . path . includes ( arg )
1305
+ ) ;
1313
1306
1314
- if ( arg_path_idx <= 0 ) {
1315
- const arg =
1316
- arg_path_idx === 0
1317
- ? node
1318
- : /** @type {import('estree').Expression } */ ( context . path . at ( arg_path_idx ) ) ;
1319
- const arg_idx = unwrap_optional ( parent . expression ) . arguments . indexOf ( arg ) ;
1320
- parent . metadata . args_with_call_expression . add ( arg_idx ) ;
1321
- }
1307
+ // -1 if this is the call expression of the render tag itself
1308
+ if ( arg_idx !== - 1 ) {
1309
+ render_tag . metadata . args_with_call_expression . add ( arg_idx ) ;
1322
1310
}
1323
1311
}
1324
1312
@@ -1548,6 +1536,9 @@ const common_visitors = {
1548
1536
) ;
1549
1537
1550
1538
node . metadata . dynamic = binding !== null && binding . kind !== 'normal' ;
1539
+ } ,
1540
+ RenderTag ( node , context ) {
1541
+ context . next ( { ...context . state , render_tag : node } ) ;
1551
1542
}
1552
1543
} ;
1553
1544
0 commit comments