diff --git a/src/core/vdom/helpers/get-first-component-child.js b/src/core/vdom/helpers/get-first-component-child.js new file mode 100644 index 00000000..70b2f199 --- /dev/null +++ b/src/core/vdom/helpers/get-first-component-child.js @@ -0,0 +1,14 @@ +/* @flow */ + +import { isDef } from 'shared/util' + +export function getFirstComponentChild (children: ?Array): ?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 + } + } + } +} diff --git a/src/core/vdom/helpers/index.js b/src/core/vdom/helpers/index.js index 3994d098..a1541e10 100644 --- a/src/core/vdom/helpers/index.js +++ b/src/core/vdom/helpers/index.js @@ -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 { - return children && children.filter((c: VNode) => c && c.componentOptions)[0] -} +export * from './get-first-component-child'