File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -134,3 +134,29 @@ export function render(_ctx) {
134
134
return n0
135
135
} "
136
136
` ;
137
+
138
+ exports [` compiler: v-if > v-if + v-if / v-else[-if] 1` ] = `
139
+ "import { setInsertionState as _setInsertionState , createIf as _createIf , template as _template } from 'vue';
140
+ const t0 = _template("<span >foo</span >")
141
+ const t1 = _template("<span >bar</span >")
142
+ const t2 = _template("<span >baz</span >")
143
+ const t3 = _template("<div ></div >", true)
144
+
145
+ export function render(_ctx) {
146
+ const n8 = t3 ()
147
+ _setInsertionState (n8 )
148
+ const n0 = _createIf (() => (_ctx .foo ), () => {
149
+ const n2 = t0 ()
150
+ return n2
151
+ })
152
+ _setInsertionState (n8 )
153
+ const n3 = _createIf (() => (_ctx .bar ), () => {
154
+ const n5 = t1 ()
155
+ return n5
156
+ }, () => {
157
+ const n7 = t2 ()
158
+ return n7
159
+ })
160
+ return n8
161
+ } "
162
+ ` ;
Original file line number Diff line number Diff line change @@ -215,6 +215,17 @@ describe('compiler: v-if', () => {
215
215
} )
216
216
} )
217
217
218
+ test ( 'v-if + v-if / v-else[-if]' , ( ) => {
219
+ const { code } = compileWithVIf (
220
+ `<div>
221
+ <span v-if="foo">foo</span>
222
+ <span v-if="bar">bar</span>
223
+ <span v-else>baz</span>
224
+ </div>` ,
225
+ )
226
+ expect ( code ) . toMatchSnapshot ( )
227
+ } )
228
+
218
229
test ( 'comment between branches' , ( ) => {
219
230
const { code, ir } = compileWithVIf ( `
220
231
<div v-if="ok"/>
Original file line number Diff line number Diff line change @@ -68,8 +68,10 @@ export function processIf(
68
68
if (
69
69
siblings [ i ] . operation &&
70
70
siblings [ i ] . operation ! . type === IRNodeTypes . IF
71
- )
71
+ ) {
72
72
lastIfNode = siblings [ i ] . operation
73
+ break
74
+ }
73
75
}
74
76
}
75
77
You can’t perform that action at this time.
0 commit comments