Side navigation
#4737 closed bug (fixed)
Opened June 08, 2009 03:42PM UTC
Closed October 15, 2010 04:41AM UTC
Last modified March 15, 2012 03:47PM UTC
repeated toggle() goes out of sync (IE8)
Reported by: | nbr | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | effects | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I tried using $(...).toggle() for two elements of which one was hidden and one visible.
Expected results: the visible one goes hidden and vice versa. The next click returns the elements as they originally were.
Actual results on IE8: the first toggling was ok, but the second click hides both elements.
See attached test case, or here: http://www.iki.fi/naapuri/testit/toggle.html
Attachments (2)
Change History (6)
Changed August 07, 2009 04:49PM UTC by comment:1
component: | unfilled → fx |
---|
Changed December 02, 2009 05:13AM UTC by comment:2
This issue is a bug in IE8 where display:none under certain circumstances will not allow the element's height and width to be 0px. Since ":hidden" checks 0 height and width, toggle() keeps trying to hide the element instead of show()-ing it.
The attached HTML file shows a simple test case with 3 span elements. The middle span element is set to display:none, but in IE8 the height is 19px and width is 4px. Earlier IE's and other browsers all show the height and width of this element at 0px.
Setting height and width to 0 manually doesn't help, and I haven't found any info on this bug on the web. So the possible solutions are a) find a method to force height/width of elements to 0 in IE8 (not sure how) or b) change ":hidden" to check display:none instead of 0'ed height and width.
Changed December 02, 2009 05:20AM UTC by comment:3
This seems to happen with inline elements that have inline elements before and after them. The problem goes away when you remove the first span.
Changed December 05, 2009 05:27AM UTC by comment:4
Actually, this is the same issue as experienced in #4512, which was solved using:
force = /^tr$/i.test( elem.nodeName ); // ticket #4512
This ticket can be resolved by adding span to that regex:
force = /^tr|span$/i.test( elem.nodeName ); // ticket #4512
However, someone has recently reopened #4512, saying they see the same issue with ul elements, and I've even seen it with divs that have display:inline, so I don't think this is a good solution. Might this be something that uses feature detection testing?
Changed October 14, 2010 09:46PM UTC by comment:5
I just found this issue (the hard way) on jQuery 1.4.2 and IE8. Using the toggle.html attached file and changing to jQuery 1.4.2, same thing happens; this is a bummer for the latest version of jQuery and IE!
A simple workaround is to use a <div style='display: inline'> instead of a <span> tag.