#6999 closed bug (duplicate)
jQuery.fn.show() changes "display" style when inline
Reported by: | chrisobrien | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | core | Version: | 1.4.2 |
Keywords: | show hide | Cc: | |
Blocked by: | Blocking: |
Description
Visit http://jsfiddle.net/GG8FD/ for a demonstration of this bug.
When jQuery.fn.show() is called on an element that is not hidden and that element has an inline CSS "display" style (as shown below), show() sets the "display" to "block":
<div id="cell" style="display:table-cell"></div>
<script type="text/javascript">
alerts "table-cell"
alert($("#cell").css("display"));
$("#cell").show();
alerts "block"
alert($("#cell").css("display"));
</script>
However, when show() is called on an element that is not hidden and that element has its "display" set in a stylesheet, show() does not change its "display":
<style type="text/css">
#cell {
display:table-cell;
}
</style>
<div id="cell"></div>
<script type="text/javascript">
alerts "table-cell"
alert($("#cell").css("display"));
$("#cell").show();
alerts "table-cell"
alert($("#cell").css("display"));
</script>
Expected result: first example (inline "display" style) should not change the "display" to "block" and instead should behave the same as second example ("display" in stylesheet).
Change History (2)
comment:1 Changed 13 years ago by
comment:2 Changed 12 years ago by
Priority: | → undecided |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Duplicate of #2185.
Also, jQuery.fn.show() sets the element.style.display value to "" if getComputedStyle() fails, which it sometimes does in Firefox if used in a currently hidden frame. The following happens in show():
old -> null
this[i].style.display -> ""
This block doesn't get executed because somewhere along jQuery.fn.css() call tree, getComputedStyles() fumbles.
this[j].style.display -> "" for a second time
In certain cases, this causes the element either to remain hidden or to eve disappear if it wasn't previously hidden.