Skip to content

Commit 1aed7a9

Browse files
authored
Merge pull request #203 from vuejs/issue-202
fix: trim slot when passed a string
2 parents e92bdcb + 7b4a803 commit 1aed7a9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/utils/compileSlots.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { compile } from '@vue/compiler-dom'
22
import * as vue from 'vue'
33

4-
export function processSlot(template = '', Vue = vue) {
4+
export function processSlot(source = '', Vue = vue) {
5+
let template = source.trim()
56
const hasWrappingTemplate = template && template.startsWith('<template')
67

78
// allow content without `template` tag, for easier testing

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)