Bug Tracker

Opened 12 years ago

Closed 12 years ago

#7797 closed bug (worksforme)

Incorrect result for css('color') in Opera browser

Reported by: [email protected] Owned by: [email protected]
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


In nearly all modern browsers, given:

<div id='test' style='color: red;')></div>

The jquery function call:

var rgb = $('#test').css('color');

yields the text: rgb(255, 0, 0)

But in Opera (versions 10 and 11), the same div and call yield the text: #ff0000

This makes programs (like farbtastic) unable to parse the RGB values.

This may be a bug in Opera, but it also seems like something that jquery could filter to minimize the browser implementation variances.

Change History (4)

comment:1 Changed 12 years ago by jitter

Owner: set to [email protected]
Status: newpending

Thanks for taking the time to contribute to the jQuery project by writing a bug report. This sounds like a bug in the plugin. Which version of farbtastic are you using?

test case with farbtastic WIP version
farbtastic old 1.2 test case

Both of the above seem to work fine in Opera (for me). So please provide a more accurate description and a test case on http://jsfiddle.net to show what doesn't work.

IMHO this isn't a bug in jQuery (does some spec say that browsers need to transform color values to rgb(x,y,z) form? link?)

Your test case yields:

  • #ff0000 in Opera 10.63/11
  • red in IE6
  • rgb(255, 0, 0) in FF 3.6.13/4.0b7, Chrome, Safari 5

As you can see from this fixing this cross-browser could get ugly as jQuery would also need to check for the basic color keywords.

Last edited 12 years ago by jitter (previous) (diff)

comment:2 Changed 12 years ago by anonymous

This has nothing to do with farbtastic; I just used that as an example, as it's how I found the problem.

Here's a complete test case. Run it in {Firefox|Safari|Chrome}, then run it in Opera.


comment:3 Changed 12 years ago by [email protected]

Status: pendingnew

Sorry. Forgot to enter my email address in my reply comment.

This could just as easily be declared a bug in Opera, especially if the CSS spec dictates the rgb(r,g,b) format. But if it doesn't, then it seems like a reasonable thing for jquery to do in the name of cross-browser compatibility.

I'd also argue that handling the rgb() plus #rrggbb formats is sufficient, if IE6 is the only borwser that returns the English word, especially if the French version of IE6 returns "rouge", etc.


comment:4 Changed 12 years ago by dmethvin

Resolution: worksforme
Status: newclosed

Returning the rgb(r,g,b) format would be bad, because IE will not accept that format as an input.

It's been this way for years, what most people do is use the color plugin which can parse a wide variety of formats:


If you truly consider it to be a bug in Opera report it to them, but it seems valid as it is.

Note: See TracTickets for help on using tickets.