diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index 60346ce9a..956227a8b 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -270,9 +270,10 @@ export default class Wrapper implements BaseWrapper { let element = this.element while (element) { if ( - element.style && - (element.style.visibility === 'hidden' || - element.style.display === 'none') + element.hidden || + (element.style && + (element.style.visibility === 'hidden' || + element.style.display === 'none')) ) { return false } diff --git a/test/specs/wrapper/isVisible.spec.js b/test/specs/wrapper/isVisible.spec.js index 359560fc7..a269f34e7 100644 --- a/test/specs/wrapper/isVisible.spec.js +++ b/test/specs/wrapper/isVisible.spec.js @@ -32,6 +32,15 @@ describeWithShallowAndMount('isVisible', mountingMethod => { expect(element.isVisible()).to.equal(false) }) + it('returns false if element has hidden attribute', () => { + const compiled = compileToFunctions( + '
' + ) + const wrapper = mountingMethod(compiled) + const element = wrapper.find('.visible') + expect(element.isVisible()).to.equal(false) + }) + it('returns true if element has v-show true', async () => { const wrapper = mountingMethod(ComponentWithVShow) wrapper.vm.$set(wrapper.vm, 'ready', true)