Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding an element using jQuery does not respect :visible selector #982

Closed
jamescookie opened this issue Dec 18, 2014 · 4 comments
Closed
Labels

Comments

@jamescookie
Copy link

I am trying to hide an element using jQuery, and then want to be able to check it is not visible using the ':visible' selector, but it does not see to work. Is this a bug?

Here is my test:

it('should hide elements', function() {
    document.body.innerHTML = '<div class="one"><div class="inner">hello</div></div>' +
                '<div class="two"><div class="inner">hello</div></div>';

    $('.one').hide();
    expect($('div.one').css('display')).to.equal('none');
    expect($('div.two').css('display')).to.equal('');
    expect($('div:visible').length).to.equal(2); // fails, reports 4
});
@domenic
Copy link
Member

domenic commented Dec 18, 2014

Hmm yeah, that would be a bug. I wonder how jQuery's non-standard :visible selector works and in what way we are failing to present as non-visible.

What version of jQuery are you using?

@domenic domenic added the bug label Dec 18, 2014
@jamescookie
Copy link
Author

I'm using jQuery 2.1.1

@Joris-van-der-Wel
Copy link
Member

jquery uses offsetWidth and offsetHeight for that. If both of those are 0, an element is :hidden and not :visible.

So #135 would have to be resolved

@domenic
Copy link
Member

domenic commented Jul 2, 2016

Rolling into #1048.

@domenic domenic closed this as completed Jul 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants