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

parser.spec.ts — vue Source File

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

File typescript 4 imports

Entity Profile

Dependency Diagram

graph LR
  782560d0_2073_3d5c_2648_a10bfd6bbe3d["parser.spec.ts"]
  d62ea118_535f_3a78_3561_bebb0acfc3aa["index"]
  782560d0_2073_3d5c_2648_a10bfd6bbe3d --> d62ea118_535f_3a78_3561_bebb0acfc3aa
  156bf2e1_8a13_f22d_5437_54f14bcef8fa["util"]
  782560d0_2073_3d5c_2648_a10bfd6bbe3d --> 156bf2e1_8a13_f22d_5437_54f14bcef8fa
  c8c25bbc_db7f_72b6_f1ee_617c071790f0["options"]
  782560d0_2073_3d5c_2648_a10bfd6bbe3d --> c8c25bbc_db7f_72b6_f1ee_617c071790f0
  b1eb2bb2_8774_a6f3_1b5c_854efafa7ee6["env"]
  782560d0_2073_3d5c_2648_a10bfd6bbe3d --> b1eb2bb2_8774_a6f3_1b5c_854efafa7ee6
  style 782560d0_2073_3d5c_2648_a10bfd6bbe3d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { parse } from 'compiler/parser/index'
import { extend } from 'shared/util'
import { baseOptions } from 'web/compiler/options'
import { isIE, isEdge } from 'core/util/env'

describe('parser', () => {
  it('simple element', () => {
    const ast = parse('<h1>hello world</h1>', baseOptions)
    expect(ast.tag).toBe('h1')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].text).toBe('hello world')
  })

  it('interpolation in element', () => {
    const ast = parse('<h1>{{msg}}</h1>', baseOptions)
    expect(ast.tag).toBe('h1')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].expression).toBe('_s(msg)')
  })

  it('child elements', () => {
    const ast = parse('<ul><li>hello world</li></ul>', baseOptions)
    expect(ast.tag).toBe('ul')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('li')
    expect(ast.children[0].plain).toBe(true)
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

  it('unary element', () => {
    const ast = parse('<hr>', baseOptions)
    expect(ast.tag).toBe('hr')
    expect(ast.plain).toBe(true)
    expect(ast.children.length).toBe(0)
  })

  it('svg element', () => {
    const ast = parse('<svg><text>hello world</text></svg>', baseOptions)
    expect(ast.tag).toBe('svg')
    expect(ast.ns).toBe('svg')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('text')
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

  it('camelCase element', () => {
    const ast = parse(
      '<MyComponent><p>hello world</p></MyComponent>',
      baseOptions
    )
    expect(ast.tag).toBe('MyComponent')
    expect(ast.plain).toBe(true)
    expect(ast.children[0].tag).toBe('p')
    expect(ast.children[0].plain).toBe(true)
    expect(ast.children[0].children[0].text).toBe('hello world')
    expect(ast.children[0].parent).toBe(ast)
  })

// ... (1090 more lines)

Dependencies

  • env
  • index
  • options
  • util

Frequently Asked Questions

What does parser.spec.ts do?
parser.spec.ts is a source file in the vue codebase, written in typescript.
What does parser.spec.ts depend on?
parser.spec.ts imports 4 module(s): env, index, options, util.
Where is parser.spec.ts in the architecture?
parser.spec.ts is located at test/unit/modules/compiler/parser.spec.ts (directory: test/unit/modules/compiler).

Analyze Your Own Codebase

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

Try Supermodel Free