Skip to content

Commit 7b576f6

Browse files
committed
fix: trim slot when passed a string
1 parent e92bdcb commit 7b576f6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/mount.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export function mount(
236236

237237
if (typeof slot === 'string') {
238238
// slot is most probably a scoped slot string or a plain string
239-
acc[name] = (props: VNodeProps) => h(processSlot(slot), props)
239+
acc[name] = (props: VNodeProps) => h(processSlot(slot.trim()), props)
240240
return acc
241241
}
242242

tests/mountingOptions/slots.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,13 @@ describe('slots', () => {
141141
})
142142

143143
it('allows passing a scoped slot via string with no destructuring using the v-slot syntax ', () => {
144+
// Note: there is intentionally a carriage return after the first ` in the scoped key.
145+
// https://github.com/vuejs/vue-test-utils-next/issues/202
144146
const wrapper = mount(ComponentWithSlots, {
145147
slots: {
146-
scoped: `<template v-slot:scoped="params"><div>Just a plain {{ params.boolean }} {{ params.string }}</div></template>`
148+
scoped: `
149+
<template v-slot:scoped="params"><div>Just a plain {{ params.boolean }} {{ params.string }}</div></template>
150+
`
147151
}
148152
})
149153

0 commit comments

Comments
 (0)