@@ -960,9 +960,12 @@ function serialize_element_spread_attributes(
960
960
* @param {import('#compiler').Component | import('#compiler').SvelteComponent | import('#compiler').SvelteSelf } node
961
961
* @param {string | import('estree').Expression } component_name
962
962
* @param {import('./types').ComponentContext } context
963
- * @returns {import('estree').Statement }
963
+ * @returns {import('estree').Statement[] }
964
964
*/
965
965
function serialize_inline_component ( node , component_name , context ) {
966
+ /** @type {import('./types').Template[] } */
967
+ const parts = [ ] ;
968
+
966
969
/** @type {Array<import('estree').Property[] | import('estree').Expression> } */
967
970
const props_and_spreads = [ ] ;
968
971
@@ -1124,37 +1127,43 @@ function serialize_inline_component(node, component_name, context) {
1124
1127
b . array ( props_and_spreads . map ( ( p ) => ( Array . isArray ( p ) ? b . object ( p ) : p ) ) )
1125
1128
) ;
1126
1129
1127
- /** @type {import('estree').Statement } */
1128
- let statement = b . stmt (
1129
- ( typeof component_name === 'string' ? b . call : b . maybe_call ) (
1130
- context . state . options . dev
1131
- ? b . call (
1132
- '$.validate_component' ,
1133
- typeof component_name === 'string' ? b . id ( component_name ) : component_name
1134
- )
1135
- : component_name ,
1136
- b . id ( '$$payload' ) ,
1137
- props_expression
1138
- )
1139
- ) ;
1130
+ /** @type {import('estree').Statement[] } */
1131
+ let statements = [
1132
+ b . stmt ( b . assignment ( '+=' , b . id ( '$$payload.out' ) , b . literal ( block_open . value ) ) ) ,
1133
+ b . stmt (
1134
+ ( typeof component_name === 'string' ? b . call : b . maybe_call ) (
1135
+ context . state . options . dev
1136
+ ? b . call (
1137
+ '$.validate_component' ,
1138
+ typeof component_name === 'string' ? b . id ( component_name ) : component_name
1139
+ )
1140
+ : component_name ,
1141
+ b . id ( '$$payload' ) ,
1142
+ props_expression
1143
+ )
1144
+ ) ,
1145
+ b . stmt ( b . assignment ( '+=' , b . id ( '$$payload.out' ) , b . literal ( block_close . value ) ) )
1146
+ ] ;
1140
1147
1141
1148
if ( custom_css_props . length > 0 ) {
1142
- statement = b . stmt (
1143
- b . call (
1144
- '$.css_props' ,
1145
- b . id ( '$$payload' ) ,
1146
- b . literal ( context . state . metadata . namespace === 'svg' ? false : true ) ,
1147
- b . object ( custom_css_props ) ,
1148
- b . thunk ( b . block ( [ statement ] ) )
1149
+ statements = [
1150
+ b . stmt (
1151
+ b . call (
1152
+ '$.css_props' ,
1153
+ b . id ( '$$payload' ) ,
1154
+ b . literal ( context . state . metadata . namespace === 'svg' ? false : true ) ,
1155
+ b . object ( custom_css_props ) ,
1156
+ b . thunk ( b . block ( statements ) )
1157
+ )
1149
1158
)
1150
- ) ;
1159
+ ] ;
1151
1160
}
1152
1161
1153
1162
if ( snippet_declarations . length > 0 ) {
1154
- statement = b . block ( [ ...snippet_declarations , statement ] ) ;
1163
+ statements . unshift ( ...snippet_declarations ) ;
1155
1164
}
1156
1165
1157
- return statement ;
1166
+ return statements ;
1158
1167
}
1159
1168
1160
1169
/**
@@ -1653,29 +1662,27 @@ const template_visitors = {
1653
1662
}
1654
1663
} ,
1655
1664
Component ( node , context ) {
1656
- const state = context . state ;
1657
- state . template . push ( block_open ) ;
1658
- const call = serialize_inline_component ( node , node . name , context ) ;
1659
- state . template . push ( t_statement ( call ) ) ;
1660
- state . template . push ( block_close ) ;
1665
+ context . state . template . push (
1666
+ ... serialize_inline_component ( node , node . name , context ) . map ( ( statement ) =>
1667
+ t_statement ( statement )
1668
+ )
1669
+ ) ;
1661
1670
} ,
1662
1671
SvelteSelf ( node , context ) {
1663
- const state = context . state ;
1664
- state . template . push ( block_open ) ;
1665
- const call = serialize_inline_component ( node , context . state . analysis . name , context ) ;
1666
- state . template . push ( t_statement ( call ) ) ;
1667
- state . template . push ( block_close ) ;
1672
+ context . state . template . push (
1673
+ ... serialize_inline_component ( node , context . state . analysis . name , context ) . map ( ( statement ) =>
1674
+ t_statement ( statement )
1675
+ )
1676
+ ) ;
1668
1677
} ,
1669
1678
SvelteComponent ( node , context ) {
1670
- const state = context . state ;
1671
- state . template . push ( block_open ) ;
1672
- const call = serialize_inline_component (
1673
- node ,
1674
- /** @type { import('estree').Expression } */ ( context . visit ( node . expression ) ) ,
1675
- context
1679
+ context . state . template . push (
1680
+ ... serialize_inline_component (
1681
+ node ,
1682
+ /** @type { import('estree').Expression } */ ( context . visit ( node . expression ) ) ,
1683
+ context
1684
+ ) . map ( ( statement ) => t_statement ( statement ) )
1676
1685
) ;
1677
- state . template . push ( t_statement ( call ) ) ;
1678
- state . template . push ( block_close ) ;
1679
1686
} ,
1680
1687
LetDirective ( node , { state } ) {
1681
1688
if ( node . expression && node . expression . type !== 'Identifier' ) {
0 commit comments