optimizer.spec.ts — vue Source File
Architecture documentation for optimizer.spec.ts, a typescript file in the vue codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2f2ff8a3_fb92_4249_5449_4c38f77d1696["optimizer.spec.ts"] 71c23c60_e463_32f9_8a85_8e36e7f91fd7["index"] 2f2ff8a3_fb92_4249_5449_4c38f77d1696 --> 71c23c60_e463_32f9_8a85_8e36e7f91fd7 09aa5370_2caa_6b33_3f44_6ac5211bd11b["util"] 2f2ff8a3_fb92_4249_5449_4c38f77d1696 --> 09aa5370_2caa_6b33_3f44_6ac5211bd11b 68f0d316_a711_a6b4_53ec_77a7d150f31b["optimizer"] 2f2ff8a3_fb92_4249_5449_4c38f77d1696 --> 68f0d316_a711_a6b4_53ec_77a7d150f31b b0b6bd3d_bce8_b3b0_ce33_925aad47348a["options"] 2f2ff8a3_fb92_4249_5449_4c38f77d1696 --> b0b6bd3d_bce8_b3b0_ce33_925aad47348a style 2f2ff8a3_fb92_4249_5449_4c38f77d1696 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
Source
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