fix(compiler-core): fix the detection of forwarded slots with v-if or v-for (#3353)

fix #3347
This commit is contained in:
HcySunYang
2021-03-23 04:34:46 +08:00
committed by GitHub
parent 6cb94752b0
commit 602b58ebd1
2 changed files with 37 additions and 11 deletions

View File

@@ -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