api.jquery.com icon indicating copy to clipboard operation
api.jquery.com copied to clipboard

Wrong return value of offset method for hidden/disconnected elements

Open fmeyertoens opened this issue 4 years ago • 0 comments

The jQuery docs state, that

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.

The return value of undefined was changed a few years ago in https://github.com/jquery/jquery/pull/2396 due to https://github.com/jquery/jquery/issues/2310. The tests are here. Now a value of { top: 0, left: 0 } is returned instead (https://github.com/jquery/jquery/blob/a684e6ba836f7c553968d7d026ed7941e1a612d8/src/offset.js#L88) and undefined is only returned for an empty jQuery object (https://github.com/jquery/jquery/blob/a684e6ba836f7c553968d7d026ed7941e1a612d8/src/offset.js#L79).

fmeyertoens avatar Nov 04 '21 11:11 fmeyertoens