Skip to content

Commit ef4b70b

Browse files
committed
fix(compiler-vapor): allow multiple children in Transition v-if branch elements
Fixes vuejs#14316
1 parent 9d30aff commit ef4b70b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/compiler-vapor/__tests__/transforms/TransformTransition.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,21 @@ describe('compiler: transition', () => {
188188
)
189189
})
190190

191+
test('does not warn with multiple children in v-if branch', () => {
192+
checkWarning(
193+
`
194+
<transition>
195+
<h1 v-if="condition">
196+
<span>True</span>
197+
<span>True</span>
198+
</h1>
199+
<h1 v-else>False</h1>
200+
</transition>
201+
`,
202+
false,
203+
)
204+
})
205+
191206
test('inject persisted when child has v-show', () => {
192207
expect(
193208
compileWithElementTransform(`

packages/compiler-vapor/src/transforms/transformTransition.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ function hasMultipleChildren(node: ElementNode): boolean {
5454
// not has v-for
5555
!findDir(c, 'for') &&
5656
// if the first child has v-if, the rest should also have v-else-if/v-else
57-
(index === 0 ? findDir(c, 'if') : hasElse(c)) &&
58-
!hasMultipleChildren(c),
57+
(index === 0 ? findDir(c, 'if') : hasElse(c)),
5958
)
6059
) {
6160
return false

0 commit comments

Comments
 (0)