@@ -510,7 +510,9 @@ export function* generate(
510510 }
511511
512512 yield _ts ( ` {\n` ) ;
513- yield * resetDirectiveComments ( 'end of v-if start' ) ;
513+ if ( isFragment ( node ) ) {
514+ yield * resetDirectiveComments ( 'end of v-if start' ) ;
515+ }
514516 let prev : CompilerDOM . TemplateChildNode | undefined ;
515517 for ( const childNode of branch . children ) {
516518 yield * generateAstNode ( childNode , parentEl , prev , componentCtxVar ) ;
@@ -557,7 +559,9 @@ export function* generate(
557559 ) ;
558560 yield _ts ( '!)' ) ; // #3102
559561 yield _ts ( ') {\n' ) ;
560- yield * resetDirectiveComments ( 'end of v-for start' ) ;
562+ if ( isFragment ( node ) ) {
563+ yield * resetDirectiveComments ( 'end of v-for start' ) ;
564+ }
561565 let prev : CompilerDOM . TemplateChildNode | undefined ;
562566 for ( const childNode of node . children ) {
563567 yield * generateAstNode ( childNode , parentEl , prev , componentCtxVar ) ;
@@ -1800,6 +1804,10 @@ export function* generate(
18001804 }
18011805}
18021806
1807+ function isFragment ( node : CompilerDOM . IfNode | CompilerDOM . ForNode ) {
1808+ return node . codegenNode && 'consequent' in node . codegenNode && 'tag' in node . codegenNode . consequent && node . codegenNode . consequent . tag === CompilerDOM . FRAGMENT ;
1809+ }
1810+
18031811export function createTsAst ( ts : typeof import ( 'typescript' ) , astHolder : any , text : string ) {
18041812 if ( astHolder . __volar_ast_text !== text ) {
18051813 astHolder . __volar_ast_text = text ;
0 commit comments