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 Dec 29, 2012 · 5 comments

Projects

None yet

4 participants

@mikesherov
Member

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.

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?

Owner
dmethvin commented Jul 1, 2013

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 Jan 26, 2014
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.

Member

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

@dmethvin dmethvin added a commit that referenced this issue Apr 20, 2015
@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 added a commit that closed this issue Apr 29, 2015
@dmethvin @arthurvr dmethvin + arthurvr 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 Apr 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment