Skip to content

Commit

Permalink
fix(compiler-core): should not remove slot node with v-else (#11150)
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX authored Jun 22, 2024
1 parent 914f064 commit e102670
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/compiler-core/__tests__/transforms/vSlot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ describe('compiler: transform component slots', () => {
expect((root as any).children[0].codegenNode.patchFlag).toMatch(
PatchFlags.DYNAMIC_SLOTS + '',
)
expect((root as any).children[0].children.length).toBe(3)
expect(generate(root).code).toMatchSnapshot()
})

Expand Down
5 changes: 1 addition & 4 deletions packages/compiler-core/src/transforms/vSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,7 @@ export function buildSlots(
break
}
}
if (prev && isTemplateNode(prev) && findDir(prev, 'if')) {
// remove node
children.splice(i, 1)
i--
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
__TEST__ && assert(dynamicSlots.length > 0)
// attach this slot to previous conditional
let conditional = dynamicSlots[
Expand Down

0 comments on commit e102670

Please sign in to comment.