Skip to content

Wrong return value of offset method for hidden/disconnected elements #1197

Open
@fmeyertoens

Description

@fmeyertoens

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 jquery/jquery#2396 due to jquery/jquery#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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions