Skip to content

Commit

Permalink
fix(runtime-core): always set invalid vnode type (#820)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
cexbrayat authored Mar 11, 2020
1 parent 206640a commit 28a9bee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 28a9bee

Please sign in to comment.