#12468 closed bug (invalid)
.offset(coords) not working correctly for hidden elements
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Offset does not place a hidden element correctly.
See the fiddle, if you click on the "show then offset" button, the hidden element shows correctly over the button thats clicked.
If you click "offset then show" while the block is hidden, it will show up in a randomly exciting offset. If the block is visible it works correctly. (The coordinates that both functions are being passed have been tested to be identical)
Change History (4)
comment:1 Changed 11 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 Changed 11 years ago by
Thanks Scott,
I disagree. If jQuery were to do nothing (or set a replicable default like 0,0), you can correctly claim that it's not meant to work on elements that aren't in the DOM. Here jquery sets a random offset, which is a bug.
comment:3 Changed 11 years ago by
Behavior for anything that is explicitly not supported is by definition undefined. Therefore this is not a bug.
comment:4 Changed 11 years ago by
Any time something is outside the scope of valid inputs, we are not obligated to create a valid output. Doing so would be making it a valid input! TL;DR: Garbage in, garbage out.
From http://api.jquery.com/offset:
Note: jQuery does not support getting the offset coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.
While it is possible to get the coordinates of elements with visibility:hidden set, display:none is excluded from the rendering tree and thus has a position that is undefined.