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

optimizer.spec.ts — vue Source File

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

File typescript 4 imports

Entity Profile

Dependency Diagram

graph LR
  f6f97bbf_c233_724c_0897_d9b3bf9400e5["optimizer.spec.ts"]
  d62ea118_535f_3a78_3561_bebb0acfc3aa["index"]
  f6f97bbf_c233_724c_0897_d9b3bf9400e5 --> d62ea118_535f_3a78_3561_bebb0acfc3aa
  156bf2e1_8a13_f22d_5437_54f14bcef8fa["util"]
  f6f97bbf_c233_724c_0897_d9b3bf9400e5 --> 156bf2e1_8a13_f22d_5437_54f14bcef8fa
  5b4afb2f_912e_cb39_5d80_54b455473aa4["optimizer"]
  f6f97bbf_c233_724c_0897_d9b3bf9400e5 --> 5b4afb2f_912e_cb39_5d80_54b455473aa4
  c8c25bbc_db7f_72b6_f1ee_617c071790f0["options"]
  f6f97bbf_c233_724c_0897_d9b3bf9400e5 --> c8c25bbc_db7f_72b6_f1ee_617c071790f0
  style f6f97bbf_c233_724c_0897_d9b3bf9400e5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { parse } from 'compiler/parser/index'
import { extend } from 'shared/util'
import { optimize } from 'compiler/optimizer'
import { baseOptions } from 'web/compiler/options'

describe('optimizer', () => {
  it('simple', () => {
    const ast = parse(
      '<h1 id="section1"><span>hello world</span></h1>',
      baseOptions
    )
    optimize(ast, baseOptions)
    expect(ast.static).toBe(true) // h1
    expect(ast.staticRoot).toBe(true)
    expect(ast.children[0].static).toBe(true) // span
  })

  it('simple with comment', () => {
    const options = extend(
      {
        comments: true
      },
      baseOptions
    )
    const ast = parse(
      '<h1 id="section1"><span>hello world</span><!--comment--></h1>',
      options
    )
    optimize(ast, options)
    expect(ast.static).toBe(true) // h1
    expect(ast.staticRoot).toBe(true)
    expect(ast.children.length).toBe(2)
    expect(ast.children[0].static).toBe(true) // span
    expect(ast.children[1].static).toBe(true) // comment
  })

  it('skip simple nodes', () => {
    const ast = parse('<h1 id="section1">hello</h1>', baseOptions)
    optimize(ast, baseOptions)
    expect(ast.static).toBe(true)
    expect(ast.staticRoot).toBe(false) // this is too simple to warrant a static tree
  })

  it('interpolation', () => {
    const ast = parse('<h1>{{msg}}</h1>', baseOptions)
    optimize(ast, baseOptions)
    expect(ast.static).toBe(false) // h1
    expect(ast.children[0].static).toBe(false) // text node with interpolation
  })

  it('nested elements', () => {
    const ast = parse('<ul><li>hello</li><li>world</li></ul>', baseOptions)
    optimize(ast, baseOptions)
    // ul
    expect(ast.static).toBe(true)
    expect(ast.staticRoot).toBe(true)
    // li
    expect(ast.children[0].static).toBe(true) // first
    expect(ast.children[1].static).toBe(true) // second
    // text node inside li
// ... (264 more lines)

Dependencies

  • index
  • optimizer
  • options
  • util

Frequently Asked Questions

What does optimizer.spec.ts do?
optimizer.spec.ts is a source file in the vue codebase, written in typescript.
What does optimizer.spec.ts depend on?
optimizer.spec.ts imports 4 module(s): index, optimizer, options, util.
Where is optimizer.spec.ts in the architecture?
optimizer.spec.ts is located at test/unit/modules/compiler/optimizer.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