(
template: string,
options: CompilerOptions & { transformText?: boolean } = {},
)
| 31 | import { transformText } from '../../src/transforms/transformText' |
| 32 | |
| 33 | function parseWithSlots( |
| 34 | template: string, |
| 35 | options: CompilerOptions & { transformText?: boolean } = {}, |
| 36 | ) { |
| 37 | const ast = parse(template, { |
| 38 | whitespace: options.whitespace, |
| 39 | }) |
| 40 | transform(ast, { |
| 41 | nodeTransforms: [ |
| 42 | transformIf, |
| 43 | transformFor, |
| 44 | ...(options.prefixIdentifiers |
| 45 | ? [trackVForSlotScopes, transformExpression] |
| 46 | : []), |
| 47 | transformSlotOutlet, |
| 48 | transformElement, |
| 49 | trackSlotScopes, |
| 50 | ...(options.transformText ? [transformText] : []), |
| 51 | ], |
| 52 | directiveTransforms: { |
| 53 | on: transformOn, |
| 54 | bind: transformBind, |
| 55 | }, |
| 56 | ...options, |
| 57 | }) |
| 58 | return { |
| 59 | root: ast, |
| 60 | slots: |
| 61 | ast.children[0].type === NodeTypes.ELEMENT |
| 62 | ? ((ast.children[0].codegenNode as VNodeCall) |
| 63 | .children as SlotsExpression) |
| 64 | : null, |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | function createSlotMatcher(obj: Record<string, any>, isDynamic = false) { |
| 69 | return { |
no test coverage detected