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 ignore nodes with no content' , ( ) => {
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 @@ -81,6 +81,9 @@ export function parse(
81
81
if ( node . type !== NodeTypes . ELEMENT ) {
82
82
return
83
83
}
84
+ if ( ! node . children . length ) {
85
+ return
86
+ }
84
87
switch ( node . tag ) {
85
88
case 'template' :
86
89
if ( ! sfc . template ) {
You can’t perform that action at this time.
0 commit comments