Skip to content

Commit 0ba9ef9

Browse files
committed
fix(vSlot): handle non-comment children when extracting slot key
1 parent 4c6ced5 commit 0ba9ef9

File tree

1 file changed

+11
-6
lines changed
  • packages/compiler-vapor/src/transforms

1 file changed

+11
-6
lines changed

packages/compiler-vapor/src/transforms/vSlot.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,17 @@ function transformComponentSlot(
9090

9191
let slotKey
9292
if (isTransitionNode(node) && nonSlotTemplateChildren.length) {
93-
const keyProp = findProp(
94-
nonSlotTemplateChildren[0] as ElementNode,
95-
'key',
96-
) as VaporDirectiveNode
97-
if (keyProp) {
98-
slotKey = keyProp.exp
93+
const nonCommentChild = nonSlotTemplateChildren.find(
94+
n => n.type !== NodeTypes.COMMENT,
95+
)
96+
if (nonCommentChild) {
97+
const keyProp = findProp(
98+
nonCommentChild as ElementNode,
99+
'key',
100+
) as VaporDirectiveNode
101+
if (keyProp) {
102+
slotKey = keyProp.exp
103+
}
99104
}
100105
}
101106

0 commit comments

Comments
 (0)