]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(transitionGroup): inner children should skip comment node (#1105)
authorunderfin <2218301630@qq.com>
Mon, 4 May 2020 14:41:48 +0000 (22:41 +0800)
committerGitHub <noreply@github.com>
Mon, 4 May 2020 14:41:48 +0000 (10:41 -0400)
packages/runtime-dom/src/components/TransitionGroup.ts

index aa8adf1437e1696279970d1dfc7e2e9d3789375a..734ba69343f5d735a266da6ff0ea64b2f7c7bf03 100644 (file)
@@ -101,7 +101,8 @@ const TransitionGroupImpl = {
       const cssTransitionProps = resolveTransitionProps(rawProps)
       const tag = rawProps.tag || Fragment
       prevChildren = children
-      children = getTransitionRawChildren(slots.default ? slots.default() : [])
+      const slotChildren = slots.default ? slots.default() : []
+      children = getTransitionRawChildren(slotChildren)
 
       for (let i = 0; i < children.length; i++) {
         const child = children[i]
@@ -110,7 +111,7 @@ const TransitionGroupImpl = {
             child,
             resolveTransitionHooks(child, cssTransitionProps, state, instance)
           )
-        } else if (__DEV__ && child.type !== Comment) {
+        } else if (__DEV__) {
           warn(`<TransitionGroup> children must be keyed.`)
         }
       }
@@ -126,7 +127,7 @@ const TransitionGroupImpl = {
         }
       }
 
-      return createVNode(tag, null, children)
+      return createVNode(tag, null, slotChildren)
     }
   }
 }
@@ -138,7 +139,9 @@ function getTransitionRawChildren(children: VNode[]): VNode[] {
     // handle fragment children case, e.g. v-for
     if (child.type === Fragment) {
       ret = ret.concat(getTransitionRawChildren(child.children as VNode[]))
-    } else {
+    }
+    // comment should be skip, e.g. v-if
+    if (child.type !== Comment) {
       ret.push(child)
     }
   }