Ticket #10880 (closed bug: invalid)
$(element).is(':visible') should return true if either offsetHeight:0 or offsetWidth:0?
| Reported by: | ppan235@… | Owned by: | ppan235@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Hi there,
At present, $(element).is(':visible') returns true _only_ if element.offsetHeight and offsetWidth are _both_ 0px.
Surely $(element).is(':visible') should be true if _either_ element.offsetHeight or offsetWidth is 0px? Isn't 0px * anything-px = 0px-squared, so element cannot be visible?
Example html follows: please check the console. Tested in Mac FF8.01 and Safari 5.1.1.
Thanks.
Pete.
Example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.js"></script>
</head>
<body>
<div id="zero-height-nonzero-width">
<div id="invisible" style='display:none;'>I am invisible</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
function dumpElement(elementId) {
var $element = $(elementId);
var element = $element[0];
console.log('\nElement id: ' + $element.attr('id'));
console.log('Visible?: ' + $element.is(':visible'));
console.log('offsetWidth: ' + element.offsetWidth);
console.log('offsetHeight: ' + element.offsetHeight);
}
dumpElement('#zero-height-nonzero-width');
dumpElement('#invisible');
});
</script>
</body>
</html>
Change History
comment:1 Changed 19 months ago by dmethvin
- Owner set to ppan235@…
- Status changed from new to pending
comment:2 Changed 19 months ago by anonymous
Sure. I'll try to get the other test cases done next week.
Pete
comment:3 Changed 18 months ago by trac-o-bot
- Status changed from pending to closed
- Resolution set to invalid
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Sounds great. Can you test with IE6/7/8 on elements including table rows and columns that are empty? That is what I believe resulted in the current code. Once you have those test cases we can consider a change.