Skip to main content

Bug Tracker

Side navigation

#12468 closed bug (invalid)

Opened September 05, 2012 12:55PM UTC

Closed September 05, 2012 01:31PM UTC

Last modified September 05, 2012 03:37PM UTC

.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:

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)

Attachments (0)
Change History (4)

Changed September 05, 2012 01:31PM UTC by scottgonzalez comment:1

resolution: → invalid
status: newclosed


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.

Changed September 05, 2012 03:01PM UTC by comment:2

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.

Changed September 05, 2012 03:03PM UTC by scottgonzalez comment:3

Behavior for anything that is explicitly not supported is by definition undefined. Therefore this is not a bug.

Changed September 05, 2012 03:37PM UTC by dmethvin comment:4

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.