Home / Function/ normalizeArrayChildren() — vue Function Reference

normalizeArrayChildren() — vue Function Reference

Architecture documentation for the normalizeArrayChildren() function in normalize-children.ts from the vue codebase.

Function typescript VueCore VDom calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  183e70ea_9ebb_f63c_dc97_904d2baf797f["normalizeArrayChildren()"]
  6a6aa84d_7f9a_89f4_4499_eb3dd1af08a8["normalize-children.ts"]
  183e70ea_9ebb_f63c_dc97_904d2baf797f -->|defined in| 6a6aa84d_7f9a_89f4_4499_eb3dd1af08a8
  212af4c6_0b5a_ad92_f29b_9db0f5709d7f["normalizeChildren()"]
  212af4c6_0b5a_ad92_f29b_9db0f5709d7f -->|calls| 183e70ea_9ebb_f63c_dc97_904d2baf797f
  ad7dd8cb_30db_4818_1d55_523b3daa1d5b["isTextNode()"]
  183e70ea_9ebb_f63c_dc97_904d2baf797f -->|calls| ad7dd8cb_30db_4818_1d55_523b3daa1d5b
  style 183e70ea_9ebb_f63c_dc97_904d2baf797f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/vdom/helpers/normalize-children.ts lines 48–99

function normalizeArrayChildren(
  children: any,
  nestedIndex?: string
): Array<VNode> {
  const res: VNode[] = []
  let i, c, lastIndex, last
  for (i = 0; i < children.length; i++) {
    c = children[i]
    if (isUndef(c) || typeof c === 'boolean') continue
    lastIndex = res.length - 1
    last = res[lastIndex]
    //  nested
    if (isArray(c)) {
      if (c.length > 0) {
        c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`)
        // merge adjacent text nodes
        if (isTextNode(c[0]) && isTextNode(last)) {
          res[lastIndex] = createTextVNode(last.text + c[0].text)
          c.shift()
        }
        res.push.apply(res, c)
      }
    } else if (isPrimitive(c)) {
      if (isTextNode(last)) {
        // merge adjacent text nodes
        // this is necessary for SSR hydration because text nodes are
        // essentially merged when rendered to HTML strings
        res[lastIndex] = createTextVNode(last.text + c)
      } else if (c !== '') {
        // convert primitive to vnode
        res.push(createTextVNode(c))
      }
    } else {
      if (isTextNode(c) && isTextNode(last)) {
        // merge adjacent text nodes
        res[lastIndex] = createTextVNode(last.text + c.text)
      } else {
        // default key for nested array children (likely generated by v-for)
        if (
          isTrue(children._isVList) &&
          isDef(c.tag) &&
          isUndef(c.key) &&
          isDef(nestedIndex)
        ) {
          c.key = `__vlist${nestedIndex}_${i}__`
        }
        res.push(c)
      }
    }
  }
  return res
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does normalizeArrayChildren() do?
normalizeArrayChildren() is a function in the vue codebase, defined in src/core/vdom/helpers/normalize-children.ts.
Where is normalizeArrayChildren() defined?
normalizeArrayChildren() is defined in src/core/vdom/helpers/normalize-children.ts at line 48.
What does normalizeArrayChildren() call?
normalizeArrayChildren() calls 1 function(s): isTextNode.
What calls normalizeArrayChildren()?
normalizeArrayChildren() is called by 1 function(s): normalizeChildren.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free