Skip to content

Commit

Permalink
fix: respect "hidden" attributes in isVisible() (#1257)
Browse files Browse the repository at this point in the history
Elements that are hidden via the HTML `hidden` attribute were being reported as being
visible by the `isVisible()` method, even though they were not actually visible in the DOM.
  • Loading branch information
stevegrunwell authored and eddyerburgh committed Jun 12, 2019
1 parent 8a74a15 commit 950763f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/test-utils/src/wrapper.js
Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions test/specs/wrapper/isVisible.spec.js
Expand Up @@ -32,6 +32,15 @@ describeWithShallowAndMount('isVisible', mountingMethod => {
expect(element.isVisible()).to.equal(false)
})

it('returns false if element has hidden attribute', () => {
const compiled = compileToFunctions(
'<div><div><span class="visible" hidden></span></div></div>'
)
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)
Expand Down

0 comments on commit 950763f

Please sign in to comment.