Skip to main content

Bug Tracker

Side navigation

#12215 closed bug (wontfix)

Opened August 07, 2012 09:12PM UTC

Closed August 08, 2012 08:26PM UTC

Last modified August 16, 2012 02:33PM UTC

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

Reported by: 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.

Attachments (0)
Change History (4)

Changed August 07, 2012 09:55PM UTC by comment:1

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.

Changed August 08, 2012 07:53PM UTC by anonymous comment:2

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.

Changed August 08, 2012 08:26PM UTC by mikesherov comment:3

component: unfileddimensions
keywords: → needsdocs
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?

Changed August 16, 2012 02:33PM UTC by dmethvin comment:4

keywords: needsdocs

#10877 has the needsdocs