Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12215 closed bug (wontfix)

outerWidth, outerheight, width, and height sometimes return a decimal value instead of an integer

Reported by: [email protected] Owned by:
Priority: low Milestone: None
Component: dimensions Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


according to the docs, width, outerwidth, height, and outerheight, are supposed to return an integer. however sometimes they return a decimal value instead. I played around with what causes this and it seems to happen when either using percentages or decimal pixel values for the margin or padding. Since browsers eventually round everything to a whole pixel, I would expect these methods to return what the browser actually renders, and in fact always return an integer like the docs describe.

You'll notice that browsers are also inconsistent in what they return for theses values.


Change History (4)

comment:1 Changed 11 years ago by [email protected]

This demonstrates it a bit better. Pretty much the same but I put the divs in a container so you know what to expect when a div margin/padding is a percentage. http://jsfiddle.net/ZGgE6/113/

comment:2 Changed 11 years ago by anonymous

From what I can gather online, there is no reliable way to get the real width and height that the browser computes, which is pretty ridiculous. If this is true than its not jquery's fault these methods don't return integers, but at the very least the documentation should be updated to mention the scenarios where the methods may not return an integer.

comment:3 Changed 11 years ago by mikesherov

Component: unfileddimensions
Keywords: needsdocs added
Priority: undecidedlow
Resolution: wontfix
Status: newclosed

Yeah, very hard to anticipate what the browser will return, and it's actually going to become more divergent in the near future with subpixel rendering becoming more prevalent. I'm reluctant to document the specific cases when this might happen, as it's likely to change very soon.

Perhaps our docs should say "tries very very hard" to return an integer. needsdocs?

comment:4 Changed 11 years ago by dmethvin

Keywords: needsdocs removed

#10877 has the needsdocs

Note: See TracTickets for help on using tickets.