Skip to main content

Bug Tracker

Side navigation

#7141 closed bug (fixed)

Opened October 11, 2010 08:32AM UTC

Closed October 11, 2010 08:41PM UTC

Last modified October 13, 2010 07:53AM UTC

$.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)
  • test.7z (0.4 KB) - added by zeljko October 11, 2010 08:32AM UTC.

    Example

Change History (7)

Changed October 11, 2010 09:04AM UTC by tomgrohl comment:1

$('#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

Changed October 11, 2010 09:31AM UTC by tomgrohl comment:2

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:

1. 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 ):

if ( !old || jQuery.data(this[i], "olddisplay") !== jQuery.css( this[i], "display" ) ) {

And then elements would show and hide correctly.

Changed October 11, 2010 03:16PM UTC by matias comment:3

I'm seing the same error with slideDown(). The bug is not in the jQuery nightly (1.4.3pre).

Changed October 11, 2010 05:35PM UTC by tomgrohl comment:4

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.

Changed October 11, 2010 08:24PM UTC by snover comment:5

component: unfiledfx
need: ReviewCommit
owner: → john
priority: undecidedblocker

Changed October 11, 2010 08:41PM UTC by john comment:6

resolution: → fixed
status: newclosed

Changed October 13, 2010 07:53AM UTC by matias comment:7

_comment0: Still having problems with RC2. Shouldn't this fix be in RC2 or am I reading the github graphs wrong? 1286959736458330

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.