Skip to main content

Bug Tracker

Side navigation

#12870 closed bug (duplicate)

Opened November 08, 2012 10:08PM UTC

Closed November 21, 2012 06:15PM UTC

Provide method to get the actual comptued value of styles

Reported by: jez Owned by: jez
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:
Description

When you call jQuery.css("styleName"), there's some chance that jQuery might return the computed style which would be returned from the window.getComputedStyle(domElement) call. However, for various styles such as width and height, jQuery instead calls a 'hook' method, like the one defined in cssHooks["width"]. The trouble is that these hooks aren't always desirable; with IE's sub-pixel rounding, for example, I want to get a computed width for an element which looks like "26.65px" and instead jQuery gives me "25px". Maybe jQuery's way is useful for something, but jQuery should provide a way to always get the computed style, as returned by the browser.

Attachments (0)
Change History (6)

Changed November 08, 2012 10:10PM UTC by jez comment:1

That should say jQuery.css(domElement, "styleName") above.

Changed November 08, 2012 10:30PM UTC by gibson042 comment:2

If getComputedStyle returns the data you want, why not use that?

Changed November 09, 2012 12:37AM UTC by mikesherov comment:3

owner: → jez
status: newpending

I agree with gibson042, why not use the native styles if that what you want? What's the use case here?

Changed November 10, 2012 05:19PM UTC by timmywil comment:4

Needs a test case.

Changed November 14, 2012 06:52PM UTC by jez comment:5

status: pendingnew

gibson042: You might as well ask why should jQuery provide you with any style information via .css(). It's for convenience, just like everything else in jQuery - it would be convenient for me to be able to just quickly get computed style information for a jQuery DOM object.

Changed November 21, 2012 06:15PM UTC by dmethvin comment:6

resolution: → duplicate
status: newclosed

Duplicate of #9628.If your fer-instance is the actual and only issue, then this is a dup.