@@ -118,10 +118,13 @@ export function processTemplate(
118118 } else if ( isTag ( node ) ) {
119119 // Process for multiple tag
120120 if ( parent . type === "expression" ) {
121- const index = parent . children . indexOf ( node ) ;
122- const before = parent . children [ index - 1 ] ;
121+ const siblings = parent . children . filter (
122+ ( n ) => n . type !== "text" || n . value . trim ( ) ,
123+ ) ;
124+ const index = siblings . indexOf ( node ) ;
125+ const before = siblings [ index - 1 ] ;
123126 if ( ! before || ! isTag ( before ) ) {
124- const after = parent . children [ index + 1 ] ;
127+ const after = siblings [ index + 1 ] ;
125128 if ( after && ( isTag ( after ) || after . type === "comment" ) ) {
126129 const start = node . position ! . start . offset ;
127130 script . appendOriginal ( start ) ;
@@ -427,10 +430,13 @@ export function processTemplate(
427430 ( isTag ( node ) || node . type === "comment" ) &&
428431 parent . type === "expression"
429432 ) {
430- const index = parent . children . indexOf ( node ) ;
431- const after = parent . children [ index + 1 ] ;
433+ const siblings = parent . children . filter (
434+ ( n ) => n . type !== "text" || n . value . trim ( ) ,
435+ ) ;
436+ const index = siblings . indexOf ( node ) ;
437+ const after = siblings [ index + 1 ] ;
432438 if ( ! after || ( ! isTag ( after ) && after . type !== "comment" ) ) {
433- const before = parent . children [ index - 1 ] ;
439+ const before = siblings [ index - 1 ] ;
434440 if ( before && ( isTag ( before ) || before . type === "comment" ) ) {
435441 const end = getEndOffset ( node , ctx ) ;
436442 script . appendOriginal ( end ) ;
0 commit comments