Bug Tracker

Opened 10 years ago

Closed 10 years ago

#12870 closed bug (duplicate)

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:


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 cssHookswidth?. 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.

Change History (6)

comment:1 in reply to:  description Changed 10 years ago by jez

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

comment:2 Changed 10 years ago by gibson042

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

comment:3 Changed 10 years ago by mikesherov

Owner: set to jez
Status: newpending

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

comment:4 Changed 10 years ago by timmywil

Needs a test case.

comment:5 Changed 10 years ago by jez

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.

comment:6 Changed 10 years ago by dmethvin

Resolution: duplicate
Status: newclosed

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

Note: See TracTickets for help on using tickets.