]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-vapor): allow multiple children in Transition v-if branch elements ...
authorCédric Exbrayat <cexbrayat@users.noreply.github.com>
Thu, 15 Jan 2026 00:22:26 +0000 (01:22 +0100)
committerGitHub <noreply@github.com>
Thu, 15 Jan 2026 00:22:26 +0000 (08:22 +0800)
close #14316

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

index 9f0dfdd72b584f81fd4eacff94cd62c2c7b883f2..909036f65f3530dfa8ec34d4efea11bbd30880fc 100644 (file)
@@ -188,6 +188,21 @@ describe('compiler: transition', () => {
     )
   })
 
+  test('does not warn with multiple children in v-if branch', () => {
+    checkWarning(
+      `
+      <transition>
+        <h1 v-if="condition">
+          <span>True</span>
+          <span>True</span>
+        </h1>
+        <h1 v-else>False</h1>
+      </transition>
+      `,
+      false,
+    )
+  })
+
   test('inject persisted when child has v-show', () => {
     expect(
       compileWithElementTransform(`
index 6014235083185475efcab86b87504e4b81fad761..cbea826ce166aa3471e380b13328c04cb079cbd0 100644 (file)
@@ -54,8 +54,7 @@ function hasMultipleChildren(node: ElementNode): boolean {
         // not has v-for
         !findDir(c, 'for') &&
         // if the first child has v-if, the rest should also have v-else-if/v-else
-        (index === 0 ? findDir(c, 'if') : hasElse(c)) &&
-        !hasMultipleChildren(c),
+        (index === 0 ? findDir(c, 'if') : hasElse(c)),
     )
   ) {
     return false