Opened 12 years ago
Closed 9 years ago
#10406 closed bug (fixed)
:hidden selector finds <br /> elements in chrome and safari (but not FF or IE)
Reported by: | Owned by: | Timmy Willison | |
---|---|---|---|
Priority: | high | Milestone: | 1.12/2.2 |
Component: | css | Version: | 1.6.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When using .find(':hidden') , Chrome and Safari return <br /> elements in addition to elements that you would expect. Firefox and IE (9) do not find <br /> elements.
Test case:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var hidden_elements = $('#test').find(':hidden'); console.log(hidden_elements); var len = hidden_elements.length; console.log(len); }) </script> </head> <body> <div id="test"> <br /> </div> </body> </html>
Change History (12)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → selector |
---|---|
Priority: | undecided → low |
Status: | new → open |
Confirmed. I thought it might be due to <br /> elements having different heights in the browser but this shows they both return 0 for height:
comment:3 Changed 12 years ago by
Owner: | set to Timmy Willison |
---|---|
Status: | open → assigned |
Sticking this here for future reference: http://jsfiddle.net/timmywil/DhddZ/6/
This offsetHeight during the selection is 19, but the offsetHeight during the height() check is 0 because it goes through swap, which applies display: block before checking because offsetWidth was 0. So, the different codepaths make sense now, but this is a pain.
Possible solution would be to check width === 0 OR height === 0, but there may be a reason why do both.
comment:4 Changed 11 years ago by
Milestone: | None → 1.next |
---|---|
Owner: | Timmy Willison deleted |
Status: | assigned → open |
comment:5 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Treat elements as hidden when either offsetWidth OR offsetHeight is 0. Fixes #13132, #10406.
Changeset: 3015ee0b5a3cae399b53314bd9a859f61de3b94a
comment:6 Changed 11 years ago by
Treat an element as hidden if either offsetWidth or offsetHeight is 0. Fixes #13132, #10406.
Changeset: 372e04e78e81cc8eb868c5fc97f271a695569aa5
comment:8 Changed 11 years ago by
Component: | selector → css |
---|---|
Priority: | low → high |
Resolution: | fixed |
Status: | closed → reopened |
comment:9 Changed 11 years ago by
Owner: | set to Timmy Willison |
---|---|
Status: | reopened → assigned |
comment:10 Changed 10 years ago by
Milestone: | 1.next → 1.11/2.1 |
---|
comment:11 Changed 10 years ago by
Milestone: | 1.11/2.1 → 1.12/2.2 |
---|
comment:12 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
CSS: elements are hidden when either offsetWidth or offsetHeight is zero
- Note: this is a breaking change that has been delayed for several versions.
Changeset: 10399ddcf8a239acc27bdec9231b996b178224d3
JSfiddle test case here: http://jsfiddle.net/DhddZ/