Skip to content

Commit 073755b

Browse files
authored
fix: return true in isEmpty if child isComment (#475)
1 parent 1da0c6e commit 073755b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/test-utils/src/wrapper.js

+3
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ export default class Wrapper implements BaseWrapper {
335335
if (!this.vnode) {
336336
return this.element.innerHTML === ''
337337
}
338+
if (this.vnode.children) {
339+
return this.vnode.children.every(vnode => vnode.isComment)
340+
}
338341
return this.vnode.children === undefined || this.vnode.children.length === 0
339342
}
340343

test/specs/wrapper/isEmpty.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ describeWithShallowAndMount('isEmpty', (mountingMethod) => {
99
expect(wrapper.isEmpty()).to.equal(true)
1010
})
1111

12+
it('returns true if node contains comment', () => {
13+
const compiled = compileToFunctions('<div><div v-if="false"></div></div>')
14+
const wrapper = mountingMethod(compiled)
15+
expect(wrapper.isEmpty()).to.equal(true)
16+
})
17+
1218
it('returns true if innerHTML is empty', () => {
1319
const TestComponent = {
1420
render (createElement) {

0 commit comments

Comments
 (0)