Closed
Description
What problem does this feature solve?
The Vue runtime allows pretty much anything to be put into the children array, and simply strips away boolean | null | undefined
:
The types on the other hand only allow string
, VNode
, or another nested array, which means we can't use short-circuit expressions to conditionally render things.
// Doesn't work - `false` is not allowed
return h('div', data, [
this.enableSomething && h(Something)
])
// We have to do
const children: VNodeChildrenArrayContents = []
this.enableSomething && children.push(h(Something))
return h('div', data, children)
// Or
return h('div', data, [
this.enableSomething ? h(Something) : []
])
What does the proposed API look like?
Add a separate type for createElement
that also allows boolean | null | undefined
, that way vnode.children
can still be the current normalised version.