Home / File/ dom-props.spec.ts — vue Source File

dom-props.spec.ts — vue Source File

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

File typescript 3 imports

Entity Profile

Dependency Diagram

graph LR
  117377f4_30f6_e3a4_1cd4_f796e3f35a07["dom-props.spec.ts"]
  db9e7bef_009d_3918_6e7d_543a36a38d75["vue"]
  117377f4_30f6_e3a4_1cd4_f796e3f35a07 --> db9e7bef_009d_3918_6e7d_543a36a38d75
  22f6e3b3_fd99_35d7_94cf_527e68438cb3["patch"]
  117377f4_30f6_e3a4_1cd4_f796e3f35a07 --> 22f6e3b3_fd99_35d7_94cf_527e68438cb3
  973389ac_8625_30a3_53ce_b1b48fae58c5["vnode"]
  117377f4_30f6_e3a4_1cd4_f796e3f35a07 --> 973389ac_8625_30a3_53ce_b1b48fae58c5
  style 117377f4_30f6_e3a4_1cd4_f796e3f35a07 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 domProps module', () => {
  it('should create an element with domProps', () => {
    const vnode = new VNode('a', { domProps: { src: 'http://localhost/' } })
    const elm = patch(null, vnode)
    expect(elm.src).toBe('http://localhost/')
  })

  it('should change the elements domProps', () => {
    const vnode1 = new VNode('a', { domProps: { src: 'http://localhost/' } })
    const vnode2 = new VNode('a', { domProps: { src: 'https://vuejs.org/' } })
    patch(null, vnode1)
    const elm = patch(vnode1, vnode2)
    expect(elm.src).toBe('https://vuejs.org/')
  })

  it('should remove the elements domProps', () => {
    const vnode1 = new VNode('a', { domProps: { src: 'http://localhost/' } })
    const vnode2 = new VNode('a', { domProps: {} })
    patch(null, vnode1)
    const elm = patch(vnode1, vnode2)
    expect(elm.src).toBe('')
  })

  it('should initialize the elements value to zero', () => {
    const vnode = new VNode('input', { domProps: { value: 0 } })
    const elm = patch(null, vnode)
    expect(elm.value).toBe('0')
  })

  it('should save raw value on element', () => {
    const value = {}
    const vnode = new VNode('input', { domProps: { value } })
    const elm = patch(null, vnode)
    expect(elm._value).toBe(value)
  })

  it('should discard vnode children if the node has innerHTML or textContent as a prop', () => {
    const vnode = new VNode('div', { domProps: { innerHTML: 'hi' } }, [
      new VNode('span'),
      new VNode('span')
    ])
    const elm = patch(null, vnode)
    expect(elm.innerHTML).toBe('hi')
    expect(vnode.children.length).toBe(0)

    const vnode2 = new VNode('div', { domProps: { textContent: 'hi' } }, [
      new VNode('span'),
      new VNode('span')
    ])
    const elm2 = patch(null, vnode2)
    expect(elm2.textContent).toBe('hi')
    expect(vnode2.children.length).toBe(0)

    const vnode3 = new VNode('div', undefined, undefined, '123')
    patch(null, vnode3)
    const elm3 = patch(vnode3, vnode2)
    expect(elm3.textContent).toBe('hi')

    const vnode4 = new VNode('div', undefined, undefined, new VNode('span'))
    patch(null, vnode4)
    const elm4 = patch(vnode4, vnode)
    expect(elm4.textContent).toBe('hi')
  })

  it('should handle mutating observed props object', done => {
    const vm = new Vue({
      data: {
        props: {
          id: 'foo'
        }
      },
      render(h) {
        return h('div', {
          domProps: this.props
        })
      }
    }).$mount()

    expect(vm.$el.id).toBe('foo')
    vm.props.id = 'bar'
    waitForUpdate(() => {
      expect(vm.$el.id).toBe('bar')
      vm.props = { id: 'baz' }
    })
      .then(() => {
        expect(vm.$el.id).toBe('baz')
      })
      .then(done)
  })
})

Dependencies

  • patch
  • vnode
  • vue

Frequently Asked Questions

What does dom-props.spec.ts do?
dom-props.spec.ts is a source file in the vue codebase, written in typescript.
What does dom-props.spec.ts depend on?
dom-props.spec.ts imports 3 module(s): patch, vnode, vue.
Where is dom-props.spec.ts in the architecture?
dom-props.spec.ts is located at test/unit/modules/vdom/modules/dom-props.spec.ts (directory: test/unit/modules/vdom/modules).

Analyze Your Own Codebase

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

Try Supermodel Free