#7141 closed bug (fixed)
$.fn.show doesn't make element visible if it was previously hidden with $.fn.hide
Reported by: | zeljko | Owned by: | john |
---|---|---|---|
Priority: | blocker | Milestone: | 1.4.3 |
Component: | effects | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery version: jQuery 1.4.3rc1
I have following html element:
<div id="test" style="display:none">Test content</div>
If I first call $('#test').hide() and then $('#test').show() element will remain invisible.
Attachments (1)
Change History (8)
Changed 12 years ago by
comment:1 Changed 12 years ago by
$('#test').show() is settings the display css to its previous settings, which is 'none' when it should use "".
I found that replacing line 6040 of jquery-1.4.3rc1.js with:
this[i].style.display = (jQuery.data(this[i], "olddisplay") && jQuery.data(this[i], "olddisplay") !== "none") ? jQuery.data(this[i], "olddisplay") : "";
will check the if the previous display in 'none' and set it to "" instead
comment:2 Changed 12 years ago by
Also if you do:
$("#test").hide();
$("#test").show();
$("#test").css("display","block");
$("#test").hide();
$("#test").show();
display: 'none'
Then the 'olddisplay' is still 'none'
So $.fn.hide needs to set the olddisplay if:
- If does not exist ( Which it does )
AND 2. The value has change since hide (or another method) was done last
This would solve that issue by changing line 6054 to ( or something like this ):
jQuery.data(this[i], "olddisplay") !== jQuery.css( this[i], "display" ) ) { |
And then elements would show and hide correctly.
comment:3 Changed 12 years ago by
I'm seing the same error with slideDown(). The bug is not in the jQuery nightly (1.4.3pre).
comment:4 Changed 12 years ago by
slideDown internally uses Show and slideUp uses hide. So it would seem fixing this issue would fix make slideDown work correctly too.
I've done a bit of a test and if you change line 6033 of $.fn.show to
if ( ( this[i].style.display === "" || this[i].style.display === "none" ) && jQuery.css( this[i], "display" ) === "none" ) {
OR
if ( this[i].style.display === "" || jQuery.css( this[i], "display" ) === "none" ) {
And ( as per my last comment) changing line 6054 to ( or something like this ):
if ( !old || jQuery.data(this[i], "olddisplay") !== jQuery.css( this[i], "display" ) ) {
it seems to resolve any issues I have and now works.
comment:5 Changed 12 years ago by
Component: | unfiled → fx |
---|---|
need: | Review → Commit |
Owner: | set to john |
Priority: | undecided → blocker |
comment:6 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 Changed 12 years ago by
Still having problems with RC2. Shouldn't this fix be in RC2 or am I reading the github graphs wrong?
UPDATE: Turns out this plugin http://plugins.jquery.com/project/uuid is blocking the 1.4.3 show(). With 1.4.2 it works. Weird.
Example