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

prefixIdentifiers.spec.ts — vue Source File

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

File typescript CompilerSFC ScriptAnalyzer 6 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  df0a1012_59c3_28fb_722a_df24d7f58ebd["prefixIdentifiers.spec.ts"]
  799ac4a1_7d08_dd24_f075_2bfd21b8092b["prefixIdentifiers.ts"]
  df0a1012_59c3_28fb_722a_df24d7f58ebd --> 799ac4a1_7d08_dd24_f075_2bfd21b8092b
  fefea729_cf80_e4f2_675b_000b41fc85a5["prefixIdentifiers"]
  df0a1012_59c3_28fb_722a_df24d7f58ebd --> fefea729_cf80_e4f2_675b_000b41fc85a5
  1502a238_61f0_9afa_8c3c_71d2bb769820["types.ts"]
  df0a1012_59c3_28fb_722a_df24d7f58ebd --> 1502a238_61f0_9afa_8c3c_71d2bb769820
  8fa13167_5ac7_0658_5752_38b3ee82910e["BindingTypes"]
  df0a1012_59c3_28fb_722a_df24d7f58ebd --> 8fa13167_5ac7_0658_5752_38b3ee82910e
  37f6742a_e305_dbdb_93f9_91e354c35178["entry-compiler"]
  df0a1012_59c3_28fb_722a_df24d7f58ebd --> 37f6742a_e305_dbdb_93f9_91e354c35178
  ce7935e3_5ccb_204b_52e5_73091c757a5d["prettier"]
  df0a1012_59c3_28fb_722a_df24d7f58ebd --> ce7935e3_5ccb_204b_52e5_73091c757a5d
  style df0a1012_59c3_28fb_722a_df24d7f58ebd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { prefixIdentifiers } from '../src/prefixIdentifiers'
import { compile } from 'web/entry-compiler'
import { format } from 'prettier'
import { BindingTypes } from '../src/types'

const toFn = (source: string) => `function render(){${source}\n}`

it('should work', () => {
  const { render } = compile(`<div id="app">
  <div :style="{ color }">{{ foo }}</div>
  <p v-for="i in list">{{ i }}</p>
  <foo inline-template>
    <div>{{ bar }}</div>
  </foo>
</div>`)

  const result = format(prefixIdentifiers(toFn(render)), {
    semi: false,
    parser: 'babel'
  })

  expect(result).not.toMatch(`_vm._c`)
  expect(result).toMatch(`_vm.foo`)
  expect(result).toMatch(`_vm.list`)
  expect(result).toMatch(`{ color: _vm.color }`)
  expect(result).not.toMatch(`_vm.i`)
  expect(result).not.toMatch(`with (this)`)

  expect(result).toMatchInlineSnapshot(`
    "function render() {
      var _vm = this,
        _c = _vm._self._c
      return _c(
        "div",
        { attrs: { id: "app" } },
        [
          _c("div", { style: { color: _vm.color } }, [_vm._v(_vm._s(_vm.foo))]),
          _vm._v(" "),
          _vm._l(_vm.list, function (i) {
            return _c("p", [_vm._v(_vm._s(i))])
          }),
          _vm._v(" "),
          _c("foo", {
            inlineTemplate: {
              render: function () {
                var _vm = this,
                  _c = _vm._self._c
                return _c("div", [_vm._v(_vm._s(_vm.bar))])
              },
              staticRenderFns: [],
            },
          }),
        ],
        2
      )
    }
    "
  `)
})

it('setup bindings', () => {
  const { render } = compile(`<div @click="count++">{{ count }}</div>`)

  const result = format(
    prefixIdentifiers(toFn(render), false, false, undefined, {
      count: BindingTypes.SETUP_REF
    }),
    {
      semi: false,
      parser: 'babel'
    }
  )

  expect(result).toMatch(`_setup = _vm._self._setupProxy`)
  expect(result).toMatch(`_setup.count++`)
  expect(result).toMatch(`_vm._s(_setup.count)`)

  expect(result).toMatchInlineSnapshot(`
    "function render() {
      var _vm = this,
        _c = _vm._self._c,
        _setup = _vm._self._setupProxy
      return _c(
        "div",
        {
          on: {
            click: function ($event) {
              _setup.count++
            },
          },
        },
        [_vm._v(_vm._s(_setup.count))]
      )
    }
    "
  `)
})

Domain

Subdomains

Functions

Frequently Asked Questions

What does prefixIdentifiers.spec.ts do?
prefixIdentifiers.spec.ts is a source file in the vue codebase, written in typescript. It belongs to the CompilerSFC domain, ScriptAnalyzer subdomain.
What functions are defined in prefixIdentifiers.spec.ts?
prefixIdentifiers.spec.ts defines 1 function(s): toFn.
What does prefixIdentifiers.spec.ts depend on?
prefixIdentifiers.spec.ts imports 6 module(s): BindingTypes, entry-compiler, prefixIdentifiers, prefixIdentifiers.ts, prettier, types.ts.
Where is prefixIdentifiers.spec.ts in the architecture?
prefixIdentifiers.spec.ts is located at packages/compiler-sfc/test/prefixIdentifiers.spec.ts (domain: CompilerSFC, subdomain: ScriptAnalyzer, directory: packages/compiler-sfc/test).

Analyze Your Own Codebase

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

Try Supermodel Free