From bb05aad6eb95818d067bde7a7e6a27e3cb7aaad0 Mon Sep 17 00:00:00 2001 From: Phil Stavri Date: Mon, 2 Oct 2017 14:28:11 +0100 Subject: [PATCH] fix: isEmpty check vnode for children length closes #63 --- src/wrappers/wrapper.js | 2 +- test/unit/specs/mount/Wrapper/isEmpty.spec.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/wrappers/wrapper.js b/src/wrappers/wrapper.js index 7288e2ce0..c4d402322 100644 --- a/src/wrappers/wrapper.js +++ b/src/wrappers/wrapper.js @@ -248,7 +248,7 @@ export default class Wrapper implements BaseWrapper { * Checks if node is empty */ isEmpty (): boolean { - return this.vnode.children === undefined + return this.vnode.children === undefined || this.vnode.children.length === 0 } /** diff --git a/test/unit/specs/mount/Wrapper/isEmpty.spec.js b/test/unit/specs/mount/Wrapper/isEmpty.spec.js index 8a89b1946..1f5f534ca 100644 --- a/test/unit/specs/mount/Wrapper/isEmpty.spec.js +++ b/test/unit/specs/mount/Wrapper/isEmpty.spec.js @@ -9,6 +9,13 @@ describe('isEmpty', () => { expect(wrapper.isEmpty()).to.equal(true) }) + it('returns true contains empty slot', () => { + const compiled = compileToFunctions('
') + const wrapper = mount(compiled) + + expect(wrapper.isEmpty()).to.equal(true) + }) + it('returns false if node contains other nodes', () => { const compiled = compileToFunctions('

') const wrapper = mount(compiled)