Skip to content

Commit b5f3287

Browse files
committed
chore: update
1 parent a952b03 commit b5f3287

File tree

3 files changed

+5
-32
lines changed

3 files changed

+5
-32
lines changed

packages/compiler-vapor/src/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class TransformContext<T extends AllNode = AllNode> {
7676

7777
inVOnce: boolean = false
7878
inVFor: number = 0
79-
inSlot: number = 0
79+
inSlot: boolean = false
8080

8181
comment: CommentNode[] = []
8282
component: Set<string> = this.ir.component

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

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
ErrorCodes,
66
NodeTypes,
77
type SimpleExpressionNode,
8-
type TemplateChildNode,
98
createCompilerError,
109
createSimpleExpression,
1110
isStaticArgOf,
@@ -100,24 +99,15 @@ export const transformSlotOutlet: NodeTransform = (node, context) => {
10099
}
101100

102101
return () => {
103-
const {
104-
block: { node: slotNode },
105-
inSlot,
106-
} = context
107-
const forwarded =
108-
inSlot !== 0 &&
109-
slotNode.type === NodeTypes.ELEMENT &&
110-
hasForwardedSlots(slotNode.children)
111-
if (forwarded) context.ir.hasForwardedSlot = true
112-
102+
if (context.inSlot) context.ir.hasForwardedSlot = true
113103
exitBlock && exitBlock()
114104
context.dynamic.operation = {
115105
type: IRNodeTypes.SLOT_OUTLET_NODE,
116106
id,
117107
name: slotName,
118108
props: irProps,
119109
fallback,
120-
forwarded,
110+
forwarded: context.inSlot,
121111
}
122112
}
123113
}
@@ -143,20 +133,3 @@ function createFallback(
143133
context.reference()
144134
return [fallback, exitBlock]
145135
}
146-
147-
function hasForwardedSlots(children: TemplateChildNode[]): boolean {
148-
for (let i = 0; i < children.length; i++) {
149-
const child = children[i]
150-
switch (child.type) {
151-
case NodeTypes.ELEMENT:
152-
if (
153-
child.tagType === ElementTypes.SLOT ||
154-
hasForwardedSlots(child.children)
155-
) {
156-
return true
157-
}
158-
break
159-
}
160-
}
161-
return false
162-
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ function createSlotBlock(
237237
const block: SlotBlockIRNode = newBlock(slotNode)
238238
block.props = dir && dir.exp
239239
const exitBlock = context.enterBlock(block)
240-
context.inSlot++
240+
context.inSlot = true
241241
return [
242242
block,
243243
() => {
244-
context.inSlot--
244+
context.inSlot = false
245245
exitBlock()
246246
},
247247
]

0 commit comments

Comments
 (0)