File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -268,7 +268,9 @@ h1 { color: red }
268
268
} )
269
269
270
270
test ( 'treat custom blocks as raw text' , ( ) => {
271
- const { errors, descriptor } = parse ( `<foo> <-& </foo>` )
271
+ const { errors, descriptor } = parse (
272
+ `<template><input></template><foo> <-& </foo>`
273
+ )
272
274
expect ( errors . length ) . toBe ( 0 )
273
275
expect ( descriptor . customBlocks [ 0 ] . content ) . toBe ( ` <-& ` )
274
276
} )
@@ -309,5 +311,13 @@ h1 { color: red }
309
311
) . errors . length
310
312
) . toBe ( 0 )
311
313
} )
314
+
315
+ // # 6676
316
+ test ( 'should throw error if no <template> or <script> is present' , ( ) => {
317
+ assertWarning (
318
+ parse ( `import { ref } from 'vue'` ) . errors ,
319
+ `At least one <template> or <script> is required in a single file component`
320
+ )
321
+ } )
312
322
} )
313
323
} )
Original file line number Diff line number Diff line change @@ -149,7 +149,6 @@ export function parse(
149
149
errors . push ( e )
150
150
}
151
151
} )
152
-
153
152
ast . children . forEach ( node => {
154
153
if ( node . type !== NodeTypes . ELEMENT ) {
155
154
return
@@ -218,7 +217,13 @@ export function parse(
218
217
break
219
218
}
220
219
} )
221
-
220
+ if ( ! descriptor . template && ! descriptor . script && ! descriptor . scriptSetup ) {
221
+ errors . push (
222
+ new SyntaxError (
223
+ `At least one <template> or <script> is required in a single file component.`
224
+ )
225
+ )
226
+ }
222
227
if ( descriptor . scriptSetup ) {
223
228
if ( descriptor . scriptSetup . src ) {
224
229
errors . push (
You can’t perform that action at this time.
0 commit comments