Bug Tracker

Opened 15 years ago

Closed 15 years ago

#476 closed bug (fixed)

Opera curCSS bug

Reported by: luke.lutman@… Owned by:
Priority: major Milestone: 1.1a
Component: core Version: 1.1a
Keywords: Cc:
Blocked by: Blocking:


In Opera (9, Mac), jQuery's css method returns property values in the units they were specified with in the stylesheet, rather than the computed value in pixels (like all other browsers).

For example: <p id="test" style="font-size: 1em">test</p>


Will return '1em', which isn't so useful.

I did a little bit of digging, and it looks like this is actually a bug. In the curCSS function, on line 452 (r627), there's a check for elem.currentStyle :

... } else if(elem.currentStyle) {

stuff that's supposed to be for IE only

} ...

Apparently, this property exists in Opera, but contains the bogus values. If that check is changed to:

... } else if(elem.currentStyle && !window.opera) { ... } ...

Then opera will use getComputedStyle and return the correct values, in pixels :-)

Change History (2)

comment:1 Changed 15 years ago by klaus.hartl@…

Instead of introducing another browser vendor check I propose the following: change the order of the if/else conditions from:

} else if (elem.currentStyle) {
} else if (document.defaultView && document.defaultView.getComputedStyle) {


} else if (document.defaultView && document.defaultView.getComputedStyle) {
} else if (elem.currentStyle) {

comment:2 Changed 15 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in SVN.

Note: See TracTickets for help on using tickets.