$.show() after $.hide() sometimes does not restore the correct display style
|Reported by:||jd||Owned by:||markelog|
The docs of $.show() state:
"With no parameters, ... the matched elements will be revealed immediately, with no animation. This is roughly equivalent to calling .css('display', 'block'), except that the display property is restored to whatever it was initially. If an element has a display value of inline, then is hidden and shown, it will once again be displayed inline."
The implementation in function showHide(elements, show) uses a data_priv variable "olddisplay" to remember the old display when hiding elements. This variable is then used to restore the display property when elements are shown.
The current implementation only sets "olddisplay" once in the first call to hide(), and then restores the display using that value in all subsequent calls to show(). If after the first call to hide() the display property was set to another value, then show() will restore display to the unwanted old value.
I illustrated the bug in http://jsfiddle.net/6XG8u/6/
To work correctly showHide() should always store the current display property when hiding elements.
Change History (7)
comment:3 Changed 3 years ago by markelog
- Component changed from unfiled to css
- Owner changed from jd to markelog
- Priority changed from undecided to low
- Status changed from new to assigned