File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -606,6 +606,27 @@ describe('compiler: v-if', () => {
606
606
expect ( branch1 . props ) . toMatchObject ( createObjectMatcher ( { key : `[0]` } ) )
607
607
} )
608
608
609
+ test ( 'with spaces between branches' , ( ) => {
610
+ const {
611
+ node : { codegenNode }
612
+ } = parseWithIfTransform (
613
+ `<div v-if="ok"/> <div v-else-if="no"/> <div v-else/>`
614
+ )
615
+ expect ( codegenNode . consequent ) . toMatchObject ( {
616
+ tag : `"div"` ,
617
+ props : createObjectMatcher ( { key : `[0]` } )
618
+ } )
619
+ const branch = codegenNode . alternate as ConditionalExpression
620
+ expect ( branch . consequent ) . toMatchObject ( {
621
+ tag : `"div"` ,
622
+ props : createObjectMatcher ( { key : `[1]` } )
623
+ } )
624
+ expect ( branch . alternate ) . toMatchObject ( {
625
+ tag : `"div"` ,
626
+ props : createObjectMatcher ( { key : `[2]` } )
627
+ } )
628
+ } )
629
+
609
630
test ( 'with comments' , ( ) => {
610
631
const { node } = parseWithIfTransform ( `
611
632
<template v-if="ok">
Original file line number Diff line number Diff line change @@ -130,6 +130,16 @@ export function processIf(
130
130
comments . unshift ( sibling )
131
131
continue
132
132
}
133
+
134
+ if (
135
+ sibling &&
136
+ sibling . type === NodeTypes . TEXT &&
137
+ ! sibling . content . trim ( ) . length
138
+ ) {
139
+ context . removeNode ( sibling )
140
+ continue
141
+ }
142
+
133
143
if ( sibling && sibling . type === NodeTypes . IF ) {
134
144
// move the node to the if node's branches
135
145
context . removeNode ( )
You can’t perform that action at this time.
0 commit comments