Home / File/ render-proxy.spec.ts — vue Source File

render-proxy.spec.ts — vue Source File

Architecture documentation for render-proxy.spec.ts, a typescript file in the vue codebase. 1 imports, 0 dependents.

File typescript 1 imports

Entity Profile

Dependency Diagram

graph LR
  0ffb8100_92eb_e1d5_fe3a_48551457ea59["render-proxy.spec.ts"]
  db9e7bef_009d_3918_6e7d_543a36a38d75["vue"]
  0ffb8100_92eb_e1d5_fe3a_48551457ea59 --> db9e7bef_009d_3918_6e7d_543a36a38d75
  style 0ffb8100_92eb_e1d5_fe3a_48551457ea59 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import Vue from 'vue'

if (typeof Proxy !== 'undefined') {
  describe('render proxy', () => {
    it('should warn missing property in render fns with `with`', () => {
      new Vue({
        template: `<div>{{ a }}</div>`
      }).$mount()
      expect(`Property or method "a" is not defined`).toHaveBeenWarned()
    })

    it('should warn missing property in render fns without `with`', () => {
      const render = function (h) {
        return h('div', [this.a])
      }
      render._withStripped = true
      new Vue({
        render
      }).$mount()
      expect(`Property or method "a" is not defined`).toHaveBeenWarned()
    })

    it('should not warn for hand-written render functions', () => {
      new Vue({
        render(h) {
          return h('div', [this.a])
        }
      }).$mount()
      expect(`Property or method "a" is not defined`).not.toHaveBeenWarned()
    })

    it('support symbols using the `in` operator in hand-written render functions', () => {
      const sym = Symbol()

      const vm = new Vue({
        created() {
          this[sym] = 'foo'
        },
        render(h) {
          if (sym in this) {
            return h('div', [this[sym]])
          }
        }
      }).$mount()

      expect(vm.$el.textContent).toBe('foo')
    })

    it('should warn properties starting with $ when found', () => {
      new Vue({
        data: { $a: 'foo' },
        template: `<div>{{ $a }}</div>`
      }).$mount()
      expect(
        `Property "$a" must be accessed with "$data.$a"`
      ).toHaveBeenWarned()
    })

    it('should warn properties starting with _ when found', () => {
      new Vue({
        data: { _foo: 'foo' },
        template: `<div>{{ _foo }}</div>`
      }).$mount()
      expect(
        `Property "_foo" must be accessed with "$data._foo"`
      ).toHaveBeenWarned()
    })

    it('should warn properties starting with $ when not found', () => {
      new Vue({
        template: `<div>{{ $a }}</div>`
      }).$mount()
      expect(`Property or method "$a" is not defined`).toHaveBeenWarned()
      expect(
        `Property "$a" must be accessed with "$data.$a"`
      ).not.toHaveBeenWarned()
    })

    it('should warn properties starting with $ when not found (with stripped)', () => {
      const render = function (h) {
        return h('p', this.$a)
      }
      render._withStripped = true
      new Vue({
        data: { $a: 'foo' },
        render
      }).$mount()
      expect(
        `Property "$a" must be accessed with "$data.$a"`
      ).toHaveBeenWarned()
    })

    it('should not warn properties starting with $ when using $data to access', () => {
      new Vue({
        data: { $a: 'foo' },
        template: `<div>{{ $data.$a }}</div>`
      }).$mount()
      expect(`Property or method "$a" is not defined`).not.toHaveBeenWarned()
    })
  })
}

Dependencies

  • vue

Frequently Asked Questions

What does render-proxy.spec.ts do?
render-proxy.spec.ts is a source file in the vue codebase, written in typescript.
What does render-proxy.spec.ts depend on?
render-proxy.spec.ts imports 1 module(s): vue.
Where is render-proxy.spec.ts in the architecture?
render-proxy.spec.ts is located at test/unit/features/instance/render-proxy.spec.ts (directory: test/unit/features/instance).

Analyze Your Own Codebase

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

Try Supermodel Free