mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-06 05:57:35 +08:00
split get-first-component-child
This commit is contained in:
parent
0a64ede2d5
commit
9467942b7a
14
src/core/vdom/helpers/get-first-component-child.js
Normal file
14
src/core/vdom/helpers/get-first-component-child.js
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,4 @@ export * from './extract-props'
|
|||||||
export * from './update-listeners'
|
export * from './update-listeners'
|
||||||
export * from './normalize-children'
|
export * from './normalize-children'
|
||||||
export * from './resolve-async-component'
|
export * from './resolve-async-component'
|
||||||
|
export * from './get-first-component-child'
|
||||||
export function getFirstComponentChild (children: ?Array<VNode>): ?VNode {
|
|
||||||
return children && children.filter((c: VNode) => c && c.componentOptions)[0]
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user