Home / File/ children.spec.ts — vue Source File

children.spec.ts — vue Source File

Architecture documentation for children.spec.ts, a typescript file in the vue codebase. 2 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  93d303a6_2add_e8cc_597e_c6677bc4fe2f["children.spec.ts"]
  b0751bbf_7c2c_dfea_301f_dc2a72bb6e6c["patch"]
  93d303a6_2add_e8cc_597e_c6677bc4fe2f --> b0751bbf_7c2c_dfea_301f_dc2a72bb6e6c
  f6868225_acf7_afdc_ebd3_15704ddb6566["vnode"]
  93d303a6_2add_e8cc_597e_c6677bc4fe2f --> f6868225_acf7_afdc_ebd3_15704ddb6566
  style 93d303a6_2add_e8cc_597e_c6677bc4fe2f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { patch } from 'web/runtime/patch'
import VNode, { createEmptyVNode } from 'core/vdom/vnode'

function prop(name) {
  return obj => {
    return obj[name]
  }
}

function map(fn, list) {
  const ret: any[] = []
  for (let i = 0; i < list.length; i++) {
    ret[i] = fn(list[i])
  }
  return ret
}

function spanNum(n) {
  if (typeof n === 'string') {
    return new VNode('span', {}, undefined, n)
  } else {
    return new VNode('span', { key: n }, undefined, n.toString())
  }
}

function shuffle(array) {
  let currentIndex = array.length
  let temporaryValue
  let randomIndex

  // while there remain elements to shuffle...
  while (currentIndex !== 0) {
    // pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex)
    currentIndex -= 1
    // and swap it with the current element.
    temporaryValue = array[currentIndex]
    array[currentIndex] = array[randomIndex]
    array[randomIndex] = temporaryValue
  }
  return array
}

const inner = prop('innerHTML')
const tag = prop('tagName')

describe('vdom patch: children', () => {
  let vnode0
  beforeEach(() => {
    vnode0 = new VNode('p', { attrs: { id: '1' } }, [
      createTextVNode('hello world')
    ])
    patch(null, vnode0)
  })

  it('should appends elements', () => {
    const vnode1 = new VNode('p', {}, [1].map(spanNum))
    const vnode2 = new VNode('p', {}, [1, 2, 3].map(spanNum))
    let elm = patch(vnode0, vnode1)
    expect(elm.children.length).toBe(1)
// ... (518 more lines)

Domain

Subdomains

Dependencies

  • patch
  • vnode

Frequently Asked Questions

What does children.spec.ts do?
children.spec.ts is a source file in the vue codebase, written in typescript. It belongs to the CompilerSFC domain, TemplateTransformer subdomain.
What functions are defined in children.spec.ts?
children.spec.ts defines 4 function(s): map, prop, shuffle, spanNum.
What does children.spec.ts depend on?
children.spec.ts imports 2 module(s): patch, vnode.
Where is children.spec.ts in the architecture?
children.spec.ts is located at test/unit/modules/vdom/patch/children.spec.ts (domain: CompilerSFC, subdomain: TemplateTransformer, directory: test/unit/modules/vdom/patch).

Analyze Your Own Codebase

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

Try Supermodel Free