fix(runtime-core/vnode): should not render boolean values in vnode children (close #574)

This commit is contained in:
Evan You
2020-01-06 11:57:19 -05:00
parent 137893a4fd
commit 84dc5a6862
2 changed files with 8 additions and 3 deletions

View File

@@ -337,7 +337,7 @@ export function createCommentVNode(
}
export function normalizeVNode<T, U>(child: VNodeChild<T, U>): VNode<T, U> {
if (child == null) {
if (child == null || typeof child === 'boolean') {
// empty placeholder
return createVNode(Comment)
} else if (isArray(child)) {
@@ -348,7 +348,7 @@ export function normalizeVNode<T, U>(child: VNodeChild<T, U>): VNode<T, U> {
// always produce all-vnode children arrays
return child.el === null ? child : cloneVNode(child)
} else {
// primitive types
// strings and numbers
return createVNode(Text, null, String(child))
}
}