From 192319dae2395f56bfb03f2be038e4759fa7cd44 Mon Sep 17 00:00:00 2001 From: fnlctrl Date: Wed, 25 Jul 2018 03:14:48 +0800 Subject: [PATCH] refactor(transition): replace nested closure with static ones --- src/platforms/web/runtime/components/transition.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/platforms/web/runtime/components/transition.js b/src/platforms/web/runtime/components/transition.js index 6111d8cbbcb..84fe82984a1 100644 --- a/src/platforms/web/runtime/components/transition.js +++ b/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 }