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.

File typescript VueCore Observer 2 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  b685c027_c152_3cc2_bfb8_b3ba1669b231["children.spec.ts"]
  22f6e3b3_fd99_35d7_94cf_527e68438cb3["patch"]
  b685c027_c152_3cc2_bfb8_b3ba1669b231 --> 22f6e3b3_fd99_35d7_94cf_527e68438cb3
  973389ac_8625_30a3_53ce_b1b48fae58c5["vnode"]
  b685c027_c152_3cc2_bfb8_b3ba1669b231 --> 973389ac_8625_30a3_53ce_b1b48fae58c5
  style b685c027_c152_3cc2_bfb8_b3ba1669b231 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 VueCore domain, Observer 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: VueCore, subdomain: Observer, 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