Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12468 closed bug (invalid)

.offset(coords) not working correctly for hidden elements

Reported by: mordy@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

Description

http://jsfiddle.net/T398c/3/

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 scottgonzalez

Resolution: invalid
Status: newclosed

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.

comment:2 Changed 11 years ago by mordy@…

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 scottgonzalez

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 dmethvin

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.

Note: See TracTickets for help on using tickets.