Skip to content

Commit 1d1e382

Browse files
philstavrieddyerburgh
authored andcommitted
fix: isEmpty check vnode for children length
closes #63
1 parent f35c9ae commit 1d1e382

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/wrappers/wrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export default class Wrapper implements BaseWrapper {
248248
* Checks if node is empty
249249
*/
250250
isEmpty (): boolean {
251-
return this.vnode.children === undefined
251+
return this.vnode.children === undefined || this.vnode.children.length === 0
252252
}
253253

254254
/**

test/unit/specs/mount/Wrapper/isEmpty.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ describe('isEmpty', () => {
99
expect(wrapper.isEmpty()).to.equal(true)
1010
})
1111

12+
it('returns true contains empty slot', () => {
13+
const compiled = compileToFunctions('<div><slot></slot></div>')
14+
const wrapper = mount(compiled)
15+
16+
expect(wrapper.isEmpty()).to.equal(true)
17+
})
18+
1219
it('returns false if node contains other nodes', () => {
1320
const compiled = compileToFunctions('<div><p /></div>')
1421
const wrapper = mount(compiled)

0 commit comments

Comments
 (0)