8000 fix(compile-vapor): ensure component node is initialized before applyVShow is called by edison1105 · Pull Request #12951 · vuejs/core · GitHub
[go: up one dir, main page]

Skip to content

fix(compile-vapor): ensure component node is initialized before applyVShow is called #12951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments. < 8000 /div>
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(compile-vapor): ensure component node is initialized before apply…
…VShow is called
  • Loading branch information
edison1105 committed Feb 26, 2025
commit 73bb298451ad02d91fb4664ece6dde4751282136
4 changes: 4 additions & 0 deletions packages/compiler-vapor/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ export class TransformContext<T extends AllNode = AllNode> {
this.block.operation.push(...node)
}

registerOperationAt(node: OperationNode, index: number): void {
this.block.operation.splice(index, 0, node)
}

create<T extends TemplateChildNode>(
node: T,
index: number,
Expand Down
16 changes: 13 additions & 3 deletions packages/compiler-vapor/src/transforms/transformElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ import {
type IRProps,
type IRPropsDynamicAttribute,
type IRPropsStatic,
type OperationNode,
type VaporDirectiveNode,
} from '../ir'
import { EMPTY_EXPRESSION } from './utils'
import { findProp } from '../utils'
import { findDir, findProp } from '../utils'

export const isReservedProp: (key: string) => boolean = /*#__PURE__*/ makeMap(
// the leading comma is intentional so empty string "" is also included
Expand Down Expand Up @@ -124,7 +125,7 @@ function transformComponentElement(
}

context.dynamic.flags |= DynamicFlag.NON_TEMPLATE | DynamicFlag.INSERT
context.registerOperation({
const op: OperationNode = {
type: IRNodeTypes.CREATE_COMPONENT_NODE,
id: context.reference(),
tag,
Expand All @@ -134,7 +135,16 @@ function transformComponentElement(
slots: [...context.slots],
once: context.inVOnce,
dynamic: dynamicComponent,
})
}
const hasVShow = findDir(node, 'show')
if (hasVShow) {
const showOperationIndex = context.block.operation.findIndex(
op => op.type === IRNodeTypes.DIRECTIVE && op.name === 'show',
)
context.registerOperationAt(op, showOperationIndex)
} else {
context.registerOperation(op)
}
context.slots = []
}

Expand Down
Loading
0