fix(compiler-core): fix the detection of forwarded slots with v-if or v-for (#3353)
fix #3347
This commit is contained in:
@@ -368,14 +368,25 @@ function buildDynamicSlot(
|
||||
function hasForwardedSlots(children: TemplateChildNode[]): boolean {
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i]
|
||||
if (child.type === NodeTypes.ELEMENT) {
|
||||
if (
|
||||
child.tagType === ElementTypes.SLOT ||
|
||||
(child.tagType === ElementTypes.ELEMENT &&
|
||||
hasForwardedSlots(child.children))
|
||||
) {
|
||||
return true
|
||||
}
|
||||
switch (child.type) {
|
||||
case NodeTypes.ELEMENT:
|
||||
if (
|
||||
child.tagType === ElementTypes.SLOT ||
|
||||
(child.tagType === ElementTypes.ELEMENT &&
|
||||
hasForwardedSlots(child.children))
|
||||
) {
|
||||
return true
|
||||
}
|
||||
break
|
||||
case NodeTypes.IF:
|
||||
if (hasForwardedSlots(child.branches)) return true
|
||||
break
|
||||
case NodeTypes.IF_BRANCH:
|
||||
case NodeTypes.FOR:
|
||||
if (hasForwardedSlots(child.children)) return true
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user