Skip to main content

Bug Tracker

Side navigation

#7725 closed bug (wontfix)

Opened December 08, 2010 09:40AM UTC

Closed April 17, 2011 08:23PM UTC

Last modified May 09, 2011 10:59AM UTC

slideUp isn't the correct opposit to slideDown

Reported by: Simon Owned by: Simon
Priority: undecided Milestone:
Component: effects Version: 1.4.4
Keywords: needsreview Cc:
Blocked by: Blocking:
Description

SlideDown make elements visible also if an ancestor has the hidden style (:visible selector).

SlideUp doesn't make an element exlicit invisible if an ancestor has the hidden style (:hidden selector).

E.g.

2 Elements: one visible and another hidden by his parent.

The span elements are hidden by default via a css hidden class.

<p style="visible: none;">
  <span class="elements hidden"></span>
<p>
<p>
  <span class="elements hidden"></span>
</p>

1)

$('.elements').slideDown();

overwrites the hidden class and make span elements explicit visible. If you call later $('p').show(); both span elements are visible.

2)

$('.elements').slideUp();

only hide the second span element in case of the first p is hidden. if you make the first p visible the span element is also visible, but your aim is to make all span.elements explicit invisible.

In contrast if you call $('.elements').hide(); all elements are invisible.

I think it's line 6416 in jQuery core-file (but I'm not sure):

if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
return opt.complete.call(this);
}

In case of a hidden ancestor IMHO it would be better to hide the element explicit, like the function hide() do it.

Attachments (0)
Change History (5)

Changed December 08, 2010 09:09PM UTC by jitter comment:1

_comment0: Thanks for taking the time to contribute to the jQuery project by writing a bug report. \ \ As you didn't provide a working live test case (on http://jsfiddle.net) and the code you posted is incomplete and partially invalid (`style="visible: none;"` ??) it's difficult to evaluate if there is any bug at all. \ \ I made this [http://jsfiddle.net/jitter/rZEf9/ test case] based on what you posted and by guessing what the markup/css looks like. I can't seem to reproduce what you are describing. \ \ Please report back with a valid test case (on http://jsfiddle.net) which reproduces the issue you are experiencing also consider adding more information (jQuery version, browser version) \ ----- \ [http://docs.jquery.com/How_to_Report_Bugs How to report bugs]1291843548037063
owner: → Simon
status: newpending

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

As you didn't provide a working live test case and the code you posted is incomplete and partially invalid (style="visible: none;" ??) it's difficult to evaluate if there is any bug at all.

I made this test case based on what you posted and by guessing what the markup/css looks like. I can't seem to reproduce what you are describing.

Please report back with a valid test case (on http://jsfiddle.net) which reproduces the issue you are experiencing also consider adding more information (jQuery version, browser version)


How to report bugs

Changed December 16, 2010 11:02PM UTC by Simon comment:2

status: pendingnew

Thank you for helping me, it's my first jQuery bug report.

Your example is almost the case that I mean, that is why I'm adopted your code and add only a hide button (test case). You can comprehend the bug when you follow this steps:

1) click slideDown

2) click show

3) click hide

4) click slideUp

5) click show <-- here you can see the bug. The "b" isn't hidden.

My environment:

jQuery Version 1.4.4,

Firefox 3.6.13 on both Mac OS 10.6 and Windows XP (German Version)

Internet Explorer 8 on Windows XP

Changed December 23, 2010 06:24PM UTC by dmethvin comment:3

component: unfiledeffects
keywords: → needsreview

I think you're advocating that if a parent is hidden, slideUp should still "hide" the child element so that when the parent is ever unhidden the child will still be hidden.

I think the current behavior is a side-effect of the way we determine visibility, which is via a 0 height/width. Not sure if we want to change this, but I can see your point about symmetry.

Changed April 17, 2011 08:23PM UTC by john comment:4

milestone: 1.6
resolution: → wontfix
status: newclosed

Yeah, I don't think that's a change that we're going to make, unfortunately.

Changed May 09, 2011 10:59AM UTC by Ariel <asjquery@dsgml.com> comment:5

I just ran into this exact same issue. Are you certain you won't fix it?

Please reconsider.

I would expect it to display: none; the element if the parent is hidden, but not animate it.

I managed to work around it by adding $(this).hide() in the callback but it seems wrong that it doesn't already do that.