Bug Tracker

Modify

Ticket #12215 (closed bug: wontfix)

Opened 10 months ago

Last modified 9 months ago

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

Reported by: aviynw@… Owned by:
Priority: low Milestone: None
Component: dimensions Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:

Description

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.

 http://jsfiddle.net/ZGgE6/108/

Change History

comment:1 Changed 10 months ago by aviynw@…

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 10 months 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 10 months ago by mikesherov

  • Keywords needsdocs added
  • Priority changed from undecided to low
  • Status changed from new to closed
  • Component changed from unfiled to dimensions
  • Resolution set to wontfix

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 9 months ago by dmethvin

  • Keywords needsdocs removed

#10877 has the needsdocs

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.