Skip to content

Commit

Permalink
chore: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Jan 1, 2024
1 parent 4b75752 commit 0bbadcf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/server-renderer/__tests__/ssrSlot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ describe('ssr: slot', () => {
createApp({
components: {
one: {
template: `<transition><slot/></transition>`,
template: `<TransitionGroup tag="div"><slot/></TransitionGroup>`,
},
},
template: `<one><p v-for="i in 2">{{i}}</p></one>`,
}),
),
).toBe(`<p>1</p><p>2</p>`)
).toBe(`<div><p>1</p><p>2</p></div>`)
})
})
10 changes: 4 additions & 6 deletions packages/server-renderer/src/helpers/ssrRenderSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,16 @@ export function ssrRenderSlotInner(
}
} else {
for (let i = 0; i < slotBuffer.length; i++) {
const buffer = slotBuffer[i]
// #9933
// Although we handle Transition/TransitionGroup in the transform stage
// without rendering them as fragments, the content passed into the slot
// without rendering it as a fragment, the content passed into the slot
// may still be a fragment.
// Therefore, here we need to avoid rendering it as a fragment again.
if (
transition &&
(slotBuffer[i] === '<!--[-->' || slotBuffer[i] === '<!--]-->')
) {
if (transition && (buffer === '<!--[-->' || buffer === '<!--]-->')) {
continue
}
push(slotBuffer[i])
push(buffer)
}
}
}
Expand Down

0 comments on commit 0bbadcf

Please sign in to comment.