Skip to content

Commit aa5f5d1

Browse files
committed
ensure $scopedSlots is always an object (close vuejs#4301)
1 parent b2b9d1c commit aa5f5d1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

flow/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ declare interface Component {
2525
$children: Array<Component>;
2626
$refs: { [key: string]: Component | Element | Array<Component | Element> | void };
2727
$slots: { [key: string]: Array<VNode> };
28-
$scopedSlots: ?{ [key: string]: () => VNodeChildren };
28+
$scopedSlots: { [key: string]: () => VNodeChildren };
2929
$vnode: VNode;
3030
$isServer: boolean;
3131

src/core/instance/render.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function initRender (vm: Component) {
1616
vm._staticTrees = null
1717
vm._renderContext = vm.$options._parentVnode && vm.$options._parentVnode.context
1818
vm.$slots = resolveSlots(vm.$options._renderChildren, vm._renderContext)
19-
vm.$scopedSlots = null
19+
vm.$scopedSlots = {}
2020
// bind the public createElement fn to this instance
2121
// so that we get proper render context inside it.
2222
vm.$createElement = bind(createElement, vm)
@@ -45,7 +45,7 @@ export function renderMixin (Vue: Class<Component>) {
4545
}
4646
}
4747

48-
if (_parentVnode) {
48+
if (_parentVnode && _parentVnode.data.scopedSlots) {
4949
vm.$scopedSlots = _parentVnode.data.scopedSlots
5050
}
5151

@@ -191,7 +191,7 @@ export function renderMixin (Vue: Class<Component>) {
191191
fallback: ?Array<VNode>,
192192
props: ?Object
193193
): ?Array<VNode> {
194-
const scopedSlotFn = this.$scopedSlots && this.$scopedSlots[name]
194+
const scopedSlotFn = this.$scopedSlots[name]
195195
if (scopedSlotFn) { // scoped slot
196196
return scopedSlotFn(props || {}) || fallback
197197
} else {

0 commit comments

Comments
 (0)