MCPcopy
hub / github.com/vuejs/core / parseWithIfTransform

Function parseWithIfTransform

packages/compiler-core/__tests__/transforms/vIf.spec.ts:35–63  ·  view source on GitHub ↗
(
  template: string,
  options: CompilerOptions = {},
  returnIndex: number = 0,
  childrenLen: number = 1,
)

Source from the content-addressed store, hash-verified

33import { createObjectMatcher } from '../testUtils'
34
35function parseWithIfTransform(
36 template: string,
37 options: CompilerOptions = {},
38 returnIndex: number = 0,
39 childrenLen: number = 1,
40) {
41 const ast = parse(template, options)
42 transform(ast, {
43 nodeTransforms: [
44 transformVBindShorthand,
45 transformIf,
46 transformSlotOutlet,
47 transformElement,
48 ],
49 ...options,
50 })
51 if (!options.onError) {
52 expect(ast.children.length).toBe(childrenLen)
53 for (let i = 0; i < childrenLen; i++) {
54 expect(ast.children[i].type).toBe(NodeTypes.IF)
55 }
56 }
57 return {
58 root: ast,
59 node: ast.children[returnIndex] as IfNode & {
60 codegenNode: IfConditionalExpression
61 },
62 }
63}
64
65describe('compiler: v-if', () => {
66 describe('transform', () => {

Callers 1

vIf.spec.tsFile · 0.85

Calls 2

transformFunction · 0.90
parseFunction · 0.50

Tested by

no test coverage detected