@@ -9,19 +9,11 @@ import * as b from '../../../../utils/builders.js';
99 */
1010export function SvelteBoundary ( node , context ) {
1111 const nodes = [ ] ;
12+
13+ const props = b . object ( [ ] ) ;
14+
1215 /** @type {Statement[] } */
1316 const snippet_statements = [ ] ;
14- /** @type {Array<Property[]> } */
15- const props = [ ] ;
16-
17- const push_prop = ( /** @type {Property } */ prop ) => {
18- let current = props . at ( - 1 ) ;
19- if ( Array . isArray ( current ) ) {
20- current . push ( prop ) ;
21- }
22- const arr = [ prop ] ;
23- props . push ( arr ) ;
24- } ;
2517
2618 for ( const attribute of node . attributes ) {
2719 // Skip non-attributes with a single value
@@ -40,11 +32,11 @@ export function SvelteBoundary(node, context) {
4032 ) ;
4133
4234 if ( attribute . metadata . expression . has_state ) {
43- push_prop (
35+ props . properties . push (
4436 b . prop ( 'get' , b . id ( attribute . name ) , b . function ( null , [ ] , b . block ( [ b . return ( value ) ] ) ) )
4537 ) ;
4638 } else {
47- push_prop ( b . prop ( 'init' , b . id ( attribute . name ) , value ) ) ;
39+ props . properties . push ( b . prop ( 'init' , b . id ( attribute . name ) , value ) ) ;
4840 }
4941 }
5042 }
@@ -54,9 +46,8 @@ export function SvelteBoundary(node, context) {
5446 if ( child . type === 'SnippetBlock' && child . expression . name === 'failed' ) {
5547 /** @type {Statement[] } */
5648 const init = [ ] ;
57- const block_state = { ...context . state , init } ;
58- context . visit ( child , block_state ) ;
59- push_prop ( b . prop ( 'init' , b . id ( 'failed' ) , b . id ( 'failed' ) ) ) ;
49+ context . visit ( child , { ...context . state , init } ) ;
50+ props . properties . push ( b . prop ( 'init' , child . expression , child . expression ) ) ;
6051 snippet_statements . push ( ...init ) ;
6152 } else {
6253 nodes . push ( child ) ;
@@ -73,9 +64,8 @@ export function SvelteBoundary(node, context) {
7364 )
7465 ) ;
7566
76- const props_expression = b . object ( props . length === 0 ? [ ] : props [ 0 ] ) ;
7767 const boundary = b . stmt (
78- b . call ( '$.boundary' , context . state . node , props_expression , b . arrow ( [ b . id ( '$$anchor' ) ] , block ) )
68+ b . call ( '$.boundary' , context . state . node , props , b . arrow ( [ b . id ( '$$anchor' ) ] , block ) )
7969 ) ;
8070
8171 context . state . template . push ( '<!>' ) ;
0 commit comments