Răsfoiți Sursa

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

宋铄运 7 ani în urmă
părinte
comite
88f687cb26
1 a modificat fișierele cu 6 adăugiri și 2 ștergeri
  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
 }
 
+const isNotTextNode = (c: VNode) => c.tag || isAsyncPlaceholder(c)
+
+const isVShowDirective = d => d.name === 'show'
+
 export default {
   name: 'transition',
   props: transitionProps,
@@ -88,7 +92,7 @@ export default {
     }
 
     // filter out text nodes (possible whitespaces)
-    children = children.filter((c: VNode) => c.tag || isAsyncPlaceholder(c))
+    children = children.filter(isNotTextNode)
     /* istanbul ignore if */
     if (!children.length) {
       return
@@ -153,7 +157,7 @@ export default {
 
     // mark v-show
     // 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
     }