Skip to content

Commit 4166e3c

Browse files
committed
Merge branch 'main' into bwsy/fix/slot
2 parents 7751efa + 781c1b0 commit 4166e3c

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -389,24 +389,32 @@ function buildDynamicSlot(
389389
return createObjectExpression(props)
390390
}
391391

392-
function hasForwardedSlots(children: TemplateChildNode[]): boolean {
392+
function hasForwardedSlots(
393+
children: TemplateChildNode[],
394+
hasBranches = false
395+
): boolean {
393396
for (let i = 0; i < children.length; i++) {
394397
const child = children[i]
395398
switch (child.type) {
396399
case NodeTypes.ELEMENT:
397400
if (
398401
child.tagType === ElementTypes.SLOT ||
399-
hasForwardedSlots(child.children)
402+
(child.tagType === ElementTypes.ELEMENT && hasBranches) ||
403+
hasForwardedSlots(child.children, hasBranches)
400404
) {
401405
return true
402406
}
403407
break
404408
case NodeTypes.IF:
405-
if (hasForwardedSlots(child.branches)) return true
409+
hasBranches = true
410+
if (hasForwardedSlots(child.branches, hasBranches)) return true
406411
break
407412
case NodeTypes.IF_BRANCH:
413+
hasBranches = true
414+
if (hasForwardedSlots(child.children, hasBranches)) return true
415+
break
408416
case NodeTypes.FOR:
409-
if (hasForwardedSlots(child.children)) return true
417+
if (hasForwardedSlots(child.children, hasBranches)) return true
410418
break
411419
default:
412420
break

packages/compiler-dom/__tests__/transforms/__snapshots__/Transition.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ return function render(_ctx, _cache) {
4141
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
4242
]))
4343
]),
44-
_: 1 /* STABLE */
44+
_: 3 /* FORWARDED */
4545
}))
4646
}
4747
}"

packages/compiler-ssr/__tests__/ssrComponent.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ describe('ssr: components', () => {
280280
]
281281
}
282282
}),
283-
_: 1 /* STABLE */
283+
_: 3 /* FORWARDED */
284284
}, _parent))
285285
}"
286286
`)
@@ -341,12 +341,12 @@ describe('ssr: components', () => {
341341
? (_openBlock(), _createBlock("div", { key: 0 }))
342342
: _createCommentVNode("v-if", true)
343343
]),
344-
_: 1 /* STABLE */
344+
_: 3 /* FORWARDED */
345345
})
346346
]
347347
}
348348
}),
349-
_: 1 /* STABLE */
349+
_: 3 /* FORWARDED */
350350
}, _parent))
351351
}"
352352
`)

packages/runtime-core/src/renderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ function baseCreateRenderer(
828828
}
829829

830830
const areChildrenSVG = isSVG && n2.type !== 'foreignObject'
831-
if (dynamicChildren) {
831+
if (dynamicChildren && dynamicChildren.length > 0) {
832832
patchBlockChildren(
833833
n1.dynamicChildren!,
834834
dynamicChildren,

0 commit comments

Comments
 (0)