@@ -79,11 +79,6 @@ export function Fragment(node, context) {
7979 context . visit ( node , state ) ;
8080 }
8181
82- if ( is_text_first ) {
83- // skip over inserted comment
84- state . init . unshift ( b . stmt ( b . call ( '$.next' ) ) ) ;
85- }
86-
8782 if ( is_single_element ) {
8883 const element = /** @type {AST.RegularElement } */ ( trimmed [ 0 ] ) ;
8984
@@ -99,13 +94,13 @@ export function Fragment(node, context) {
9994 const template = transform_template ( state , namespace , flags ) ;
10095 state . hoisted . push ( b . var ( template_name , template ) ) ;
10196
102- state . init . push ( b . var ( id , b . call ( template_name ) ) ) ;
97+ state . init . unshift ( b . var ( id , b . call ( template_name ) ) ) ;
10398 close = b . stmt ( b . call ( '$.append' , b . id ( '$$anchor' ) , id ) ) ;
10499 } else if ( is_single_child_not_needing_template ) {
105100 context . visit ( trimmed [ 0 ] , state ) ;
106101 } else if ( trimmed . length === 1 && trimmed [ 0 ] . type === 'Text' ) {
107102 const id = b . id ( context . state . scope . generate ( 'text' ) ) ;
108- state . init . push ( b . var ( id , b . call ( '$.text' , b . literal ( trimmed [ 0 ] . data ) ) ) ) ;
103+ state . init . unshift ( b . var ( id , b . call ( '$.text' , b . literal ( trimmed [ 0 ] . data ) ) ) ) ;
109104 close = b . stmt ( b . call ( '$.append' , b . id ( '$$anchor' ) , id ) ) ;
110105 } else if ( trimmed . length > 0 ) {
111106 const id = b . id ( context . state . scope . generate ( 'fragment' ) ) ;
@@ -123,7 +118,7 @@ export function Fragment(node, context) {
123118 state
124119 } ) ;
125120
126- state . init . push ( b . var ( id , b . call ( '$.text' ) ) ) ;
121+ state . init . unshift ( b . var ( id , b . call ( '$.text' ) ) ) ;
127122 close = b . stmt ( b . call ( '$.append' , b . id ( '$$anchor' ) , id ) ) ;
128123 } else {
129124 if ( is_standalone ) {
@@ -166,6 +161,11 @@ export function Fragment(node, context) {
166161 body . push ( b . if ( b . call ( '$.aborted' ) , b . return ( ) ) ) ;
167162 }
168163
164+ if ( is_text_first ) {
165+ // skip over inserted comment
166+ body . push ( b . stmt ( b . call ( '$.next' ) ) ) ;
167+ }
168+
169169 body . push ( ...state . init ) ;
170170
171171 if ( state . update . length > 0 ) {
0 commit comments