File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
packages/language-core/lib/plugins Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ interface Loc {
88}
99type Node = CompilerDOM . RootNode | CompilerDOM . TemplateChildNode | CompilerDOM . ExpressionNode | CompilerDOM . AttributeNode | CompilerDOM . DirectiveNode ;
1010
11+ const shouldAddSuffix = / (?< = < [ ^ > / ] + ) $ / ;
12+
1113const plugin : VueLanguagePlugin = ( { modules } ) => {
1214
1315 return {
@@ -20,14 +22,36 @@ const plugin: VueLanguagePlugin = ({ modules }) => {
2022
2123 const compiler = modules [ '@vue/compiler-dom' ] ;
2224
23- return compiler . compile ( template , {
25+ let addedSuffix = false ;
26+
27+ // #4583
28+ if ( shouldAddSuffix . test ( template ) ) {
29+ template += '>' ;
30+ addedSuffix = true ;
31+ }
32+
33+ const result = compiler . compile ( template , {
2434 ...options ,
2535 comments : true ,
2636 } ) ;
37+ // @ts -expect-error
38+ result . __addedSuffix = addedSuffix ;
39+ return result ;
2740 }
2841 } ,
2942
3043 updateSFCTemplate ( oldResult , change ) {
44+ oldResult . code = oldResult . code . slice ( 0 , change . start )
45+ + change . newText
46+ + oldResult . code . slice ( change . end ) ;
47+
48+ // @ts -expect-error
49+ if ( oldResult . __addedSuffix ) {
50+ const originalTemplate = oldResult . code . slice ( 0 , - 1 ) ; // remove added '>'
51+ if ( ! shouldAddSuffix . test ( originalTemplate ) ) {
52+ return undefined ;
53+ }
54+ }
3155
3256 const CompilerDOM = modules [ '@vue/compiler-dom' ] ;
3357
You can’t perform that action at this time.
0 commit comments