Browse Source

refactor(transition): replace nested closure with static ones (#8547)

宋铄运 7 years ago
parent
commit
88f687cb26
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/platforms/web/runtime/components/transition.js

+ 6 - 2
src/platforms/web/runtime/components/transition.js

@@ -76,6 +76,10 @@ function isSameChild (child: VNode, oldChild: VNode): boolean {
   return oldChild.key === child.key && oldChild.tag === child.tag
   return oldChild.key === child.key && oldChild.tag === child.tag
 }
 }
 
 
+const isNotTextNode = (c: VNode) => c.tag || isAsyncPlaceholder(c)
+
+const isVShowDirective = d => d.name === 'show'
+
 export default {
 export default {
   name: 'transition',
   name: 'transition',
   props: transitionProps,
   props: transitionProps,
@@ -88,7 +92,7 @@ export default {
     }
     }
 
 
     // filter out text nodes (possible whitespaces)
     // filter out text nodes (possible whitespaces)
-    children = children.filter((c: VNode) => c.tag || isAsyncPlaceholder(c))
+    children = children.filter(isNotTextNode)
     /* istanbul ignore if */
     /* istanbul ignore if */
     if (!children.length) {
     if (!children.length) {
       return
       return
@@ -153,7 +157,7 @@ export default {
 
 
     // mark v-show
     // mark v-show
     // so that the transition module can hand over the control to the directive
     // so that the transition module can hand over the control to the directive
-    if (child.data.directives && child.data.directives.some(d => d.name === 'show')) {
+    if (child.data.directives && child.data.directives.some(isVShowDirective)) {
       child.data.show = true
       child.data.show = true
     }
     }