Skip to main content

Bug Tracker

Side navigation

#476 closed bug (fixed)

Opened December 08, 2006 12:53AM UTC

Closed December 11, 2006 09:25AM UTC

Opera curCSS bug

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

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>

$('#test').css('font-size')

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 :-)

Attachments (0)
Change History (2)

Changed December 08, 2006 01:16AM UTC by klaus.hartl@ comment:1

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) {
...

to:

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

Changed December 11, 2006 09:25AM UTC by joern comment:2

resolution: → fixed
status: newclosed

Fixed in SVN.