Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Attempting to get dimensions of a hidden div that has a percentage width/height set will result in incorrect results #197

Closed
mikesherov opened this Issue · 5 comments

4 participants

@mikesherov
Collaborator

Please see: http://bugs.jquery.com/ticket/9945
http://bugs.jquery.com/ticket/9945#comment:18

My suggestion is to mention that querying the dimensions of hidden elements (either directly, or children of hidden elements) is discouraged, and may produce incorrect results under certain circumstances like getting the pixel width of an element that was set with a percentage.

@dmethvin
Owner

This seems really esoteric to attempt to document in the API docs, and it would apply to several methods making it even messier. Can the ticket serve as the Google Beacon of Anguish to warn all future developers?

@dmethvin
Owner

I've changed my mind on this, let's document width/height to say that the results obtained from hidden elements are not guaranteed to be reliable.

@dmethvin dmethvin was assigned
@dmethvin
Owner

"Doctor, what's wrong with my API?"
"It's inaccurate!"
"I want a second opinion!"
"OK, it's slow too!"

jquery/jquery#2108

This is related to the problem of forcing layout.

@arthurvr
Collaborator

Dave, you got assigned to this, is this something you'd like to take?

@dmethvin dmethvin referenced this issue from a commit
@dmethvin dmethvin Dimensions: Update hidden element note
Add information about it being bad practice, inaccurate, and subject to removal
in a future version of jQuery. It probably causes cancer too.

Fixes #197
fe75598
@dmethvin dmethvin closed this issue from a commit
@dmethvin dmethvin Dimensions: Update hidden element note
Add information about it being bad practice, inaccurate, and subject to removal
in a future version of jQuery. It probably causes cancer too.

Fixes gh-197
Closes gh-721
1344eb3
@dmethvin dmethvin closed this in 1344eb3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.