Skip to content

Commit 2fa6e6f

Browse files
committed
support slot default content
1 parent 0e940ac commit 2fa6e6f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Diff for: src/compiler/codegen/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function genSlot (el) {
121121
const name = el.name
122122
? `"${el.name}"`
123123
: (el.dynamicName || '"default"')
124-
return `$slots[${name}]`
124+
return `($slots[${name}] || ${genChildren(el)})`
125125
}
126126

127127
function genProps (props) {

Diff for: src/runtime/instance/render.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,18 @@ export function renderMixin (Vue) {
106106
this.$options._renderKey = key
107107
this.$options._renderData = data
108108
this.$options._renderChildren = children
109-
if (children) {
110-
this.$forceUpdate()
111-
return
112-
}
113109
// set props - this will trigger update if any of them changed
110+
// but not guaranteed
114111
if (data) {
115112
updateProps(this, data)
116113
}
114+
// for now, if the component has content it always updates
115+
// because we don't know whether the children have changed.
116+
// need to optimize in the future.
117+
if (children) {
118+
this.$forceUpdate()
119+
return
120+
}
117121
}
118122

119123
Vue.prototype._render = function () {

0 commit comments

Comments
 (0)