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

element.spec.ts — vue Source File

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

File typescript 3 imports

Entity Profile

Dependency Diagram

graph LR
  68aa777e_a2f3_5e84_476f_3a2ddf832452["element.spec.ts"]
  db9e7bef_009d_3918_6e7d_543a36a38d75["vue"]
  68aa777e_a2f3_5e84_476f_3a2ddf832452 --> db9e7bef_009d_3918_6e7d_543a36a38d75
  22f6e3b3_fd99_35d7_94cf_527e68438cb3["patch"]
  68aa777e_a2f3_5e84_476f_3a2ddf832452 --> 22f6e3b3_fd99_35d7_94cf_527e68438cb3
  973389ac_8625_30a3_53ce_b1b48fae58c5["vnode"]
  68aa777e_a2f3_5e84_476f_3a2ddf832452 --> 973389ac_8625_30a3_53ce_b1b48fae58c5
  style 68aa777e_a2f3_5e84_476f_3a2ddf832452 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import Vue from 'vue'
import { patch } from 'web/runtime/patch'
import VNode from 'core/vdom/vnode'

describe('vdom patch: element', () => {
  it('should create an element', () => {
    const vnode = new VNode('p', { attrs: { id: '1' } }, [
      createTextVNode('hello world')
    ])
    const elm = patch(null, vnode)
    expect(elm.tagName).toBe('P')
    expect(elm.outerHTML).toBe('<p id="1">hello world</p>')
  })

  it('should create an element which having the namespace', () => {
    const vnode = new VNode('svg', {})
    vnode.ns = 'svg'
    const elm = patch(null, vnode)
    expect(elm.namespaceURI).toBe('http://www.w3.org/2000/svg')
  })

  const el = document.createElement('unknown')
  // Android Browser <= 4.2 doesn't use correct class name,
  // but it doesn't matter because no one's gonna use it as their primary
  // development browser.
  if (/HTMLUnknownElement/.test(el.toString())) {
    it('should warn unknown element', () => {
      const vnode = new VNode('unknown')
      patch(null, vnode)
      expect(`Unknown custom element: <unknown>`).toHaveBeenWarned()
    })
  }

  it('should warn unknown element with hyphen', () => {
    const vnode = new VNode('unknown-foo')
    patch(null, vnode)
    expect(`Unknown custom element: <unknown-foo>`).toHaveBeenWarned()
  })

  it('should create an elements which having text content', () => {
    const vnode = new VNode('div', {}, [createTextVNode('hello world')])
    const elm = patch(null, vnode)
    expect(elm.innerHTML).toBe('hello world')
  })

  it('should create an elements which having span and text content', () => {
    const vnode = new VNode('div', {}, [
      new VNode('span'),
      createTextVNode('hello world')
    ])
    const elm = patch(null, vnode)
    expect(elm.childNodes[0].tagName).toBe('SPAN')
    expect(elm.childNodes[1].textContent).toBe('hello world')
  })

  it('should create element with scope attribute', () => {
    const vnode = new VNode('div')
    vnode.context = new Vue({ _scopeId: 'foo' })
    const elm = patch(null, vnode)
    expect(elm.hasAttribute('foo')).toBe(true)
  })
})

Dependencies

  • patch
  • vnode
  • vue

Frequently Asked Questions

What does element.spec.ts do?
element.spec.ts is a source file in the vue codebase, written in typescript.
What does element.spec.ts depend on?
element.spec.ts imports 3 module(s): patch, vnode, vue.
Where is element.spec.ts in the architecture?
element.spec.ts is located at test/unit/modules/vdom/patch/element.spec.ts (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