File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,14 @@ import { mockWarn } from '@vue/runtime-test'
3
3
4
4
describe ( 'compiler:sfc' , ( ) => {
5
5
mockWarn ( )
6
+
7
+ test ( 'should not process if not children' , ( ) => {
8
+ expect ( parse ( `<template/>` ) . template ) . toBe ( null )
9
+ expect ( parse ( `<script/>` ) . script ) . toBe ( null )
10
+ expect ( parse ( `<style/>` ) . styles . length ) . toBe ( 0 )
11
+ expect ( parse ( `<custom/>` ) . customBlocks . length ) . toBe ( 0 )
12
+ } )
13
+
6
14
describe ( 'error' , ( ) => {
7
15
test ( 'should only allow single template element' , ( ) => {
8
16
parse ( `<template><div/></template><template><div/></template>` )
Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ export function parse(
74
74
if ( node . type !== NodeTypes . ELEMENT ) {
75
75
return
76
76
}
77
+ if ( ! node . children . length ) {
78
+ return
79
+ }
77
80
switch ( node . tag ) {
78
81
case 'template' :
79
82
if ( ! sfc . template ) {
You can’t perform that action at this time.
0 commit comments