chore: shorten option name
This commit is contained in:
parent
caccf92721
commit
b61d9652dd
@ -16,7 +16,7 @@ import { isString, isArray } from '@vue/shared'
|
|||||||
import { CompilerError, defaultOnError } from './errors'
|
import { CompilerError, defaultOnError } from './errors'
|
||||||
import { TO_STRING, COMMENT, CREATE_VNODE, FRAGMENT } from './runtimeConstants'
|
import { TO_STRING, COMMENT, CREATE_VNODE, FRAGMENT } from './runtimeConstants'
|
||||||
import { isVSlot, createBlockExpression, isSlotOutlet } from './utils'
|
import { isVSlot, createBlockExpression, isSlotOutlet } from './utils'
|
||||||
import { hoistStaticTrees } from './transforms/hoistStatic'
|
import { hoistStatic } from './transforms/hoistStatic'
|
||||||
|
|
||||||
// There are two types of transforms:
|
// There are two types of transforms:
|
||||||
//
|
//
|
||||||
@ -51,7 +51,7 @@ export interface TransformOptions {
|
|||||||
nodeTransforms?: NodeTransform[]
|
nodeTransforms?: NodeTransform[]
|
||||||
directiveTransforms?: { [name: string]: DirectiveTransform }
|
directiveTransforms?: { [name: string]: DirectiveTransform }
|
||||||
prefixIdentifiers?: boolean
|
prefixIdentifiers?: boolean
|
||||||
hoistStaticTrees?: boolean
|
hoistStatic?: boolean
|
||||||
onError?: (error: CompilerError) => void
|
onError?: (error: CompilerError) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ function createTransformContext(
|
|||||||
root: RootNode,
|
root: RootNode,
|
||||||
{
|
{
|
||||||
prefixIdentifiers = false,
|
prefixIdentifiers = false,
|
||||||
hoistStaticTrees = false,
|
hoistStatic = false,
|
||||||
nodeTransforms = [],
|
nodeTransforms = [],
|
||||||
directiveTransforms = {},
|
directiveTransforms = {},
|
||||||
onError = defaultOnError
|
onError = defaultOnError
|
||||||
@ -102,7 +102,7 @@ function createTransformContext(
|
|||||||
vOnce: 0
|
vOnce: 0
|
||||||
},
|
},
|
||||||
prefixIdentifiers,
|
prefixIdentifiers,
|
||||||
hoistStaticTrees,
|
hoistStatic,
|
||||||
nodeTransforms,
|
nodeTransforms,
|
||||||
directiveTransforms,
|
directiveTransforms,
|
||||||
onError,
|
onError,
|
||||||
@ -204,8 +204,8 @@ function createTransformContext(
|
|||||||
export function transform(root: RootNode, options: TransformOptions) {
|
export function transform(root: RootNode, options: TransformOptions) {
|
||||||
const context = createTransformContext(root, options)
|
const context = createTransformContext(root, options)
|
||||||
traverseNode(root, context)
|
traverseNode(root, context)
|
||||||
if (options.hoistStaticTrees) {
|
if (options.hoistStatic) {
|
||||||
hoistStaticTrees(root, context)
|
hoistStatic(root, context)
|
||||||
}
|
}
|
||||||
finalizeRoot(root, context)
|
finalizeRoot(root, context)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import { TransformContext } from '../transform'
|
|||||||
import { CREATE_VNODE } from '../runtimeConstants'
|
import { CREATE_VNODE } from '../runtimeConstants'
|
||||||
import { PropsExpression } from './transformElement'
|
import { PropsExpression } from './transformElement'
|
||||||
|
|
||||||
export function hoistStaticTrees(root: RootNode, context: TransformContext) {
|
export function hoistStatic(root: RootNode, context: TransformContext) {
|
||||||
walk(root.children, context, new Set<TemplateChildNode>())
|
walk(root.children, context, new Set<TemplateChildNode>())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ function compileToFunction(
|
|||||||
options?: CompilerOptions
|
options?: CompilerOptions
|
||||||
): RenderFunction {
|
): RenderFunction {
|
||||||
const { code } = compile(template, {
|
const { code } = compile(template, {
|
||||||
hoistStaticTrees: true,
|
hoistStatic: true,
|
||||||
...options
|
...options
|
||||||
})
|
})
|
||||||
return new Function(code)() as RenderFunction
|
return new Function(code)() as RenderFunction
|
||||||
|
Loading…
x
Reference in New Issue
Block a user