From 7c389606a482b0932f5073f0e6e9f84b9f2216c0 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 18 Oct 2018 18:01:38 -0400 Subject: [PATCH] fix: should always generate slot for non-null children --- packages/core/src/h.ts | 2 ++ packages/core/src/vdom.ts | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/src/h.ts b/packages/core/src/h.ts index 86ab1846..b9b43b2b 100644 --- a/packages/core/src/h.ts +++ b/packages/core/src/h.ts @@ -109,6 +109,8 @@ export const h = ((tag: ElementType, data?: any, children?: any): VNode => { // if value is observable, create a clone of original // so that we can normalize its class/style + // since this guard is only placed here, this means any direct createXXXVnode + // functions only accept fresh data objects. if (isObservable(data)) { data = Object.assign({}, data) } diff --git a/packages/core/src/vdom.ts b/packages/core/src/vdom.ts index 7ebcb600..6d7b5525 100644 --- a/packages/core/src/vdom.ts +++ b/packages/core/src/vdom.ts @@ -217,12 +217,11 @@ export function createComponentVNode( if (isFunction(children)) { // function as children slots = { default: children } - } else if (isArray(children) || (children as any)._isVNode) { - // direct vnode children - slots = { default: () => children } - } else if (isObject(children)) { + } else if (isObject(children) && !(children as any)._isVNode) { // slot object as children slots = children + } else { + slots = { default: () => children } } slots = normalizeSlots(slots) }