diff --git a/packages/compiler-vapor/__tests__/transforms/__snapshots__/TransformTransition.spec.ts.snap b/packages/compiler-vapor/__tests__/transforms/__snapshots__/TransformTransition.spec.ts.snap index 37ae42ed4..2cb5c36e4 100644 --- a/packages/compiler-vapor/__tests__/transforms/__snapshots__/TransformTransition.spec.ts.snap +++ b/packages/compiler-vapor/__tests__/transforms/__snapshots__/TransformTransition.spec.ts.snap @@ -74,18 +74,18 @@ exports[`compiler: transition > v-show + appear 1`] = ` const t0 = _template("

foo

") export function render(_ctx) { - const lazyApplyVShowFn = [] + const deferredApplyVShows = [] const n1 = _createComponent(_VaporTransition, { appear: () => (""), persisted: () => ("") }, { "default": () => { const n0 = t0() - lazyApplyVShowFn.push(() => _applyVShow(n0, () => (_ctx.show))) + deferredApplyVShows.push(() => _applyVShow(n0, () => (_ctx.show))) return n0 } }, true) - lazyApplyVShowFn.forEach(fn => fn()) + deferredApplyVShows.forEach(fn => fn()) return n1 }" `; diff --git a/packages/compiler-vapor/src/generators/block.ts b/packages/compiler-vapor/src/generators/block.ts index e7f0610ac..944a5ee3a 100644 --- a/packages/compiler-vapor/src/generators/block.ts +++ b/packages/compiler-vapor/src/generators/block.ts @@ -44,8 +44,8 @@ export function genBlockContent( const { dynamic, effect, operation, returns, key } = block const resetBlock = context.enterBlock(block) - if (block.hasLazyApplyVShow) { - push(NEWLINE, `const lazyApplyVShowFn = []`) + if (block.hasDeferredVShow) { + push(NEWLINE, `const deferredApplyVShows = []`) } if (root) { @@ -60,8 +60,8 @@ export function genBlockContent( push(...genOperations(operation, context)) push(...genEffects(effect, context)) - if (block.hasLazyApplyVShow) { - push(NEWLINE, `lazyApplyVShowFn.forEach(fn => fn())`) + if (block.hasDeferredVShow) { + push(NEWLINE, `deferredApplyVShows.forEach(fn => fn())`) } if (dynamic.needsKey) { diff --git a/packages/compiler-vapor/src/generators/vShow.ts b/packages/compiler-vapor/src/generators/vShow.ts index 701127916..5ff6b257d 100644 --- a/packages/compiler-vapor/src/generators/vShow.ts +++ b/packages/compiler-vapor/src/generators/vShow.ts @@ -7,15 +7,15 @@ export function genVShow( oper: DirectiveIRNode, context: CodegenContext, ): CodeFragment[] { - const { lazy, element } = oper + const { deferred, element } = oper return [ NEWLINE, - lazy ? `lazyApplyVShowFn.push(() => ` : undefined, + deferred ? `deferredApplyVShows.push(() => ` : undefined, ...genCall(context.helper('applyVShow'), `n${element}`, [ `() => (`, ...genExpression(oper.dir.exp!, context), `)`, ]), - lazy ? `)` : undefined, + deferred ? `)` : undefined, ] } diff --git a/packages/compiler-vapor/src/ir/index.ts b/packages/compiler-vapor/src/ir/index.ts index 7cd93b015..b4126863f 100644 --- a/packages/compiler-vapor/src/ir/index.ts +++ b/packages/compiler-vapor/src/ir/index.ts @@ -56,7 +56,7 @@ export interface BlockIRNode extends BaseIRNode { operation: OperationNode[] expressions: SimpleExpressionNode[] returns: number[] - hasLazyApplyVShow: boolean + hasDeferredVShow: boolean } export interface RootIRNode { @@ -188,7 +188,7 @@ export interface DirectiveIRNode extends BaseIRNode { builtin?: boolean asset?: boolean modelType?: 'text' | 'dynamic' | 'radio' | 'checkbox' | 'select' - lazy?: boolean + deferred?: boolean } export interface CreateComponentIRNode extends BaseIRNode { diff --git a/packages/compiler-vapor/src/transforms/utils.ts b/packages/compiler-vapor/src/transforms/utils.ts index 99056d44c..a42f47eb3 100644 --- a/packages/compiler-vapor/src/transforms/utils.ts +++ b/packages/compiler-vapor/src/transforms/utils.ts @@ -31,7 +31,7 @@ export const newBlock = (node: BlockIRNode['node']): BlockIRNode => ({ returns: [], expressions: [], tempId: 0, - hasLazyApplyVShow: false, + hasDeferredVShow: false, }) export function wrapTemplate(node: ElementNode, dirs: string[]): TemplateNode { diff --git a/packages/compiler-vapor/src/transforms/vShow.ts b/packages/compiler-vapor/src/transforms/vShow.ts index 3622cf0ff..a60b20a71 100644 --- a/packages/compiler-vapor/src/transforms/vShow.ts +++ b/packages/compiler-vapor/src/transforms/vShow.ts @@ -30,16 +30,16 @@ export const transformVShow: DirectiveTransform = (dir, node, context) => { } // lazy apply vshow if the node is inside a transition with appear - let lazyApplyVShow = false + let shouldDeferred = false const parentNode = context.parent && context.parent.node if (parentNode && parentNode.type === NodeTypes.ELEMENT) { - lazyApplyVShow = !!( + shouldDeferred = !!( isTransitionTag(parentNode.tag) && findProp(parentNode, 'appear', false, true) ) - if (lazyApplyVShow) { - context.parent!.parent!.block.hasLazyApplyVShow = true + if (shouldDeferred) { + context.parent!.parent!.block.hasDeferredVShow = true } } @@ -49,6 +49,6 @@ export const transformVShow: DirectiveTransform = (dir, node, context) => { dir, name: 'show', builtin: true, - lazy: lazyApplyVShow, + deferred: shouldDeferred, }) }