split get-first-component-child

This commit is contained in:
Evan You 2017-04-05 13:04:07 +08:00
parent 0a64ede2d5
commit 9467942b7a
2 changed files with 15 additions and 4 deletions

View File

@ -0,0 +1,14 @@
/* @flow */
import { isDef } from 'shared/util'
export function getFirstComponentChild (children: ?Array<VNode>): ?VNode {
if (Array.isArray(children)) {
for (let i = 0; i < children.length; i++) {
const c = children[i]
if (isDef(c) && isDef(c.componentOptions)) {
return c
}
}
}
}

View File

@ -5,7 +5,4 @@ export * from './extract-props'
export * from './update-listeners'
export * from './normalize-children'
export * from './resolve-async-component'
export function getFirstComponentChild (children: ?Array<VNode>): ?VNode {
return children && children.filter((c: VNode) => c && c.componentOptions)[0]
}
export * from './get-first-component-child'