@@ -1076,26 +1076,7 @@ function create_block(parent, name, nodes, context) {
1076
1076
}
1077
1077
}
1078
1078
if ( state . update . length > 0 ) {
1079
- let render ;
1080
- if ( state . update . length === 1 && state . update [ 0 ] . singular ) {
1081
- render = state . update [ 0 ] . singular ;
1082
- } else {
1083
- render = b . stmt (
1084
- b . call (
1085
- '$.render_effect' ,
1086
- b . thunk (
1087
- b . block (
1088
- state . update . map ( ( n ) => {
1089
- if ( n . init ) {
1090
- body . push ( n . init ) ;
1091
- }
1092
- return n . grouped ;
1093
- } )
1094
- )
1095
- )
1096
- )
1097
- ) ;
1098
- }
1079
+ const render = serialize_render_stmt ( state , body ) ;
1099
1080
if ( ! update ) {
1100
1081
update = render ;
1101
1082
}
@@ -1135,6 +1116,35 @@ function create_block(parent, name, nodes, context) {
1135
1116
return body ;
1136
1117
}
1137
1118
1119
+ /**
1120
+ *
1121
+ * @param {import('../types.js').ComponentClientTransformState } state
1122
+ * @param {import('estree').Statement[] } body
1123
+ */
1124
+ function serialize_render_stmt ( state , body ) {
1125
+ let render ;
1126
+ if ( state . update . length === 1 && state . update [ 0 ] . singular ) {
1127
+ render = state . update [ 0 ] . singular ;
1128
+ } else {
1129
+ render = b . stmt (
1130
+ b . call (
1131
+ '$.render_effect' ,
1132
+ b . thunk (
1133
+ b . block (
1134
+ state . update . map ( ( n ) => {
1135
+ if ( n . init ) {
1136
+ body . push ( n . init ) ;
1137
+ }
1138
+ return n . grouped ;
1139
+ } )
1140
+ )
1141
+ )
1142
+ )
1143
+ ) ;
1144
+ }
1145
+ return render ;
1146
+ }
1147
+
1138
1148
/**
1139
1149
* Serializes the event handler function of the `on:` directive
1140
1150
* @param {Pick<import('#compiler').OnDirective, 'name' | 'modifiers' | 'expression'> } node
@@ -2041,27 +2051,7 @@ export const template_visitors = {
2041
2051
}
2042
2052
}
2043
2053
if ( inner_context . state . update . length > 0 ) {
2044
- let render ;
2045
- if ( inner_context . state . update . length === 1 && inner_context . state . update [ 0 ] . singular ) {
2046
- render = inner_context . state . update [ 0 ] . singular ;
2047
- } else {
2048
- render = b . stmt (
2049
- b . call (
2050
- '$.render_effect' ,
2051
- b . thunk (
2052
- b . block (
2053
- inner_context . state . update . map ( ( n ) => {
2054
- if ( n . init ) {
2055
- inner . push ( n . init ) ;
2056
- }
2057
- return n . grouped ;
2058
- } )
2059
- )
2060
- )
2061
- )
2062
- ) ;
2063
- }
2064
- inner . push ( render ) ;
2054
+ inner . push ( serialize_render_stmt ( inner_context . state , inner ) ) ;
2065
2055
}
2066
2056
}
2067
2057
inner . push ( ...inner_context . state . after_update ) ;
0 commit comments