33 extract_paths ,
44 is_event_attribute ,
55 is_text_attribute ,
6- object
6+ object ,
7+ unwrap_optional
78} from '../../../../utils/ast.js' ;
89import { binding_properties } from '../../../bindings.js' ;
910import {
@@ -1864,18 +1865,18 @@ export const template_visitors = {
18641865 } ,
18651866 RenderTag ( node , context ) {
18661867 context . state . template . push ( '<!>' ) ;
1867- const binding = context . state . scope . get ( node . expression . name ) ;
1868- const is_reactive = binding ?. kind !== 'normal' || node . expression . type !== 'Identifier' ;
1868+ const callee = unwrap_optional ( node . expression ) . callee ;
1869+ const raw_args = unwrap_optional ( node . expression ) . arguments ;
1870+ const is_reactive =
1871+ callee . type !== 'Identifier' || context . state . scope . get ( callee . name ) ?. kind !== 'normal' ;
18691872
18701873 /** @type {import('estree').Expression[] } */
18711874 const args = [ context . state . node ] ;
1872- for ( const arg of node . arguments ) {
1875+ for ( const arg of raw_args ) {
18731876 args . push ( b . thunk ( /** @type {import('estree').Expression } */ ( context . visit ( arg ) ) ) ) ;
18741877 }
18751878
1876- let snippet_function = /** @type {import('estree').Expression } */ (
1877- context . visit ( node . expression )
1878- ) ;
1879+ let snippet_function = /** @type {import('estree').Expression } */ ( context . visit ( callee ) ) ;
18791880 if ( context . state . options . dev ) {
18801881 snippet_function = b . call ( '$.validate_snippet' , snippet_function ) ;
18811882 }
@@ -1885,7 +1886,14 @@ export const template_visitors = {
18851886 b . stmt ( b . call ( '$.snippet_effect' , b . thunk ( snippet_function ) , ...args ) )
18861887 ) ;
18871888 } else {
1888- context . state . after_update . push ( b . stmt ( b . call ( snippet_function , ...args ) ) ) ;
1889+ context . state . after_update . push (
1890+ b . stmt (
1891+ ( node . expression . type === 'CallExpression' ? b . call : b . maybe_call ) (
1892+ snippet_function ,
1893+ ...args
1894+ )
1895+ )
1896+ ) ;
18891897 }
18901898 } ,
18911899 AnimateDirective ( node , { state, visit } ) {
0 commit comments