* fix:create empty vnode when functional component return null * add test * use isDef
@@ -99,7 +99,7 @@ export function _createElement (
// direct component options / constructor
vnode = createComponent(tag, data, context, children)
}
- if (vnode !== undefined) {
+ if (isDef(vnode)) {
if (ns) applyNS(vnode, ns)
return vnode
} else {
@@ -1,4 +1,5 @@
import Vue from 'vue'
+import { createEmptyVNode } from 'core/vdom/vnode'
describe('Options functional', () => {
it('should work', done => {
@@ -167,4 +168,21 @@ describe('Options functional', () => {
vm.$destroy()
}).then(done)
})
+
+ it('create empty vnode when render return null', () => {
+ const child = {
+ functional: true,
+ render () {
+ return null
+ }
+ const vm = new Vue({
+ components: {
+ child
+ })
+ const h = vm.$createElement
+ const vnode = h('child')
+ expect(vnode).toEqual(createEmptyVNode())