Side navigation
#10406 closed bug (fixed)
Opened October 02, 2011 11:26PM UTC
Closed July 18, 2014 12:32AM UTC
:hidden selector finds <br /> elements in chrome and safari (but not FF or IE)
Reported by: | jen@littlegreenpixel.com | Owned by: | timmywil |
---|---|---|---|
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>
Attachments (0)
Change History (12)
Changed October 02, 2011 11:42PM UTC by comment:1
Changed October 07, 2011 12:40AM UTC by comment:2
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:
Changed October 07, 2011 02:49PM UTC by comment:3
owner: | → timmywil |
---|---|
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.
Changed October 22, 2012 05:43PM UTC by comment:4
milestone: | None → 1.next |
---|---|
owner: | timmywil |
status: | assigned → open |
Changed January 21, 2013 10:13PM UTC by comment:5
Changed January 21, 2013 10:13PM UTC by comment:6
Changed January 21, 2013 11:04PM UTC by comment:7
For reference: http://jsbin.com/oduyax/1
Changed January 31, 2013 03:23AM UTC by comment:8
component: | selector → css |
---|---|
priority: | low → high |
resolution: | fixed |
status: | closed → reopened |
Changed January 31, 2013 03:23AM UTC by comment:9
owner: | → timmywil |
---|---|
status: | reopened → assigned |
Changed May 06, 2013 07:59PM UTC by comment:10
milestone: | 1.next → 1.11/2.1 |
---|
Changed December 16, 2013 06:52PM UTC by comment:11
milestone: | 1.11/2.1 → 1.12/2.2 |
---|
JSfiddle test case here: http://jsfiddle.net/DhddZ/