]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): always set invalid vnode type (#820)
authorCédric Exbrayat <cexbrayat@users.noreply.github.com>
Wed, 11 Mar 2020 20:44:14 +0000 (21:44 +0100)
committerGitHub <noreply@github.com>
Wed, 11 Mar 2020 20:44:14 +0000 (16:44 -0400)
Currently, when a component used is not properly registered, we have a warning and the vnode type is set to a Comment type in DEV mode. But in prod mode, we have no default value, making such an application broken and throw a strange error (`can not read _isSuspense of undefined`).

This commit avoids such an error in prod mode (as it is currently the case in Vue 2.x).

packages/runtime-core/src/vnode.ts

index 46089491191b9f330d79ed095f76e2cb4d3572c1..e122091145dfba8e6d26e3f1a8616d00e6f870e8 100644 (file)
@@ -209,8 +209,10 @@ export function createVNode(
   patchFlag: number = 0,
   dynamicProps: string[] | null = null
 ): VNode {
-  if (__DEV__ && !type) {
-    warn(`Invalid vnode type when creating vnode: ${type}.`)
+  if (!type) {
+    if (__DEV__) {
+      warn(`Invalid vnode type when creating vnode: ${type}.`)
+    }
     type = Comment
   }