Bug Tracker

Ticket #7141 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

$.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:
Blocking: Blocked by:

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

test.7z Download (445 bytes) - added by zeljko 4 years ago.
Example

Change History

Changed 4 years ago by zeljko

Example

comment:1 Changed 4 years ago by tomgrohl

$('#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 4 years ago by tomgrohl

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.

comment:3 Changed 4 years ago by matias

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

comment:4 Changed 4 years ago by tomgrohl

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 4 years ago by snover

  • need changed from Review to Commit
  • Owner set to john
  • Component changed from unfiled to fx
  • Priority changed from undecided to blocker

comment:6 Changed 4 years ago by john

  • Status changed from new to closed
  • Resolution set to fixed

comment:7 Changed 4 years ago by matias

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.

Last edited 4 years ago by matias (previous) (diff)
Note: See TracTickets for help on using tickets.