diff --git a/src/core/vdom/create-element.js b/src/core/vdom/create-element.js index b9c1d0889ac..daa29b80ada 100644 --- a/src/core/vdom/create-element.js +++ b/src/core/vdom/create-element.js @@ -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 { diff --git a/test/unit/features/options/functional.spec.js b/test/unit/features/options/functional.spec.js index 9345b60e045..9bdff840aca 100644 --- a/test/unit/features/options/functional.spec.js +++ b/test/unit/features/options/functional.spec.js @@ -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()) + }) })