Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit e102670

Browse files
authored
fix(compiler-core): should not remove slot node with v-else (#11150)
1 parent 914f064 commit e102670

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

packages/compiler-core/__tests__/transforms/vSlot.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ describe('compiler: transform component slots', () => {
696696
expect((root as any).children[0].codegenNode.patchFlag).toMatch(
697697
PatchFlags.DYNAMIC_SLOTS + '',
698698
)
699+
expect((root as any).children[0].children.length).toBe(3)
699700
expect(generate(root).code).toMatchSnapshot()
700701
})
701702

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,7 @@ export function buildSlots(
226226
break
227227
}
228228
}
229-
if (prev && isTemplateNode(prev) && findDir(prev, 'if')) {
230-
// remove node
231-
children.splice(i, 1)
232-
i--
229+
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
233230
__TEST__ && assert(dynamicSlots.length > 0)
234231
// attach this slot to previous conditional
235232
let conditional = dynamicSlots[

0 commit comments

Comments
 (0)