Skip to content

Commit 8aa151b

Browse files
committed
feat: add support for rendering named slots (vuejs#887)
1 parent e8d9547 commit 8aa151b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/shared/stub-components.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ export function createBlankStub (
110110
return {
111111
...getCoreProperties(componentOptions),
112112
render (h, context) {
113+
let innerContent = null
114+
if (context) {
115+
innerContent = context.children
116+
} else {
117+
innerContent = Object.keys(this.$slots).map(slotName => {
118+
const slot = this.$slots[slotName]
119+
if (slotName !== 'default') {
120+
return slot
121+
} else {
122+
const element = h('div', { class: `${slotName}-slot` }, slot)
123+
return element
124+
}
125+
})
126+
}
113127
return h(
114128
tagName,
115129
{
@@ -124,7 +138,7 @@ export function createBlankStub (
124138
...this.$props
125139
}
126140
},
127-
context ? context.children : this.$slots.default
141+
innerContent
128142
)
129143
}
130144
}

0 commit comments

Comments
 (0)