]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: should always generate slot for non-null children
authorEvan You <yyx990803@gmail.com>
Thu, 18 Oct 2018 22:01:38 +0000 (18:01 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 18 Oct 2018 22:01:38 +0000 (18:01 -0400)
packages/core/src/h.ts
packages/core/src/vdom.ts

index 86ab1846a82bbb1435cf53a336c5d73c18420759..b9b43b2b66676320f2c17372a9a6cc6ad38fa730 100644 (file)
@@ -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)
   }
index 7ebcb600ead71ece5b1f72cb42b94bdafaa7a26c..6d7b5525bd65c828205b65e5f27b6abaf0d74ee2 100644 (file)
@@ -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)
     }