Skip to content

Commit 0bbadcf

Browse files
committed
chore: improve code
1 parent 4b75752 commit 0bbadcf

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/server-renderer/__tests__/ssrSlot.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ describe('ssr: slot', () => {
145145
createApp({
146146
components: {
147147
one: {
148-
template: `<transition><slot/></transition>`,
148+
template: `<TransitionGroup tag="div"><slot/></TransitionGroup>`,
149149
},
150150
},
151151
template: `<one><p v-for="i in 2">{{i}}</p></one>`,
152152
}),
153153
),
154-
).toBe(`<p>1</p><p>2</p>`)
154+
).toBe(`<div><p>1</p><p>2</p></div>`)
155155
})
156156
})

packages/server-renderer/src/helpers/ssrRenderSlot.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,16 @@ export function ssrRenderSlotInner(
8383
}
8484
} else {
8585
for (let i = 0; i < slotBuffer.length; i++) {
86+
const buffer = slotBuffer[i]
8687
// #9933
8788
// Although we handle Transition/TransitionGroup in the transform stage
88-
// without rendering them as fragments, the content passed into the slot
89+
// without rendering it as a fragment, the content passed into the slot
8990
// may still be a fragment.
9091
// Therefore, here we need to avoid rendering it as a fragment again.
91-
if (
92-
transition &&
93-
(slotBuffer[i] === '<!--[-->' || slotBuffer[i] === '<!--]-->')
94-
) {
92+
if (transition && (buffer === '<!--[-->' || buffer === '<!--]-->')) {
9593
continue
9694
}
97-
push(slotBuffer[i])
95+
push(buffer)
9896
}
9997
}
10098
}

0 commit comments

Comments
 (0)