#7725 closed bug (wontfix)
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.
Change History (5)
comment:1 Changed 12 years ago by
Owner: | set to Simon |
---|---|
Status: | new → pending |
comment:2 Changed 12 years ago by
Status: | pending → new |
---|
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
comment:3 Changed 12 years ago by
Component: | unfiled → effects |
---|---|
Keywords: | needsreview added |
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.
comment:4 Changed 12 years ago by
Milestone: | 1.6 |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Yeah, I don't think that's a change that we're going to make, unfortunately.
comment:5 Changed 12 years ago by
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.
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 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