Skip to main content

Bug Tracker

Side navigation

#7797 closed bug (worksforme)

Opened December 16, 2010 10:21PM UTC

Closed December 17, 2010 12:21AM UTC

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

Reported by: jhaungs@gmail.com Owned by: jhaungs@gmail.com
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

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.

Attachments (0)
Change History (4)

Changed December 16, 2010 11:22PM UTC by jitter comment:1

_comment0: 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? \ \ [http://jsfiddle.net/jitter/W6wFm/ test case] with [https://github.com/mattfarina/farbtastic farbtastic WIP version]\\\\ \ [http://acko.net/dev/farbtastic 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?) \ \ - #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 [http://www.w3.org/TR/css3-color/#html4 basic color keywords].1292541815801543
owner: → jhaungs@gmail.com
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.

Changed December 16, 2010 11:59PM UTC by anonymous comment:2

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.

http://jsfiddle.net/8FQgQ/

Changed December 17, 2010 12:04AM UTC by jhaungs@gmail.com comment:3

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.

Jim

Changed December 17, 2010 12:21AM UTC by dmethvin comment:4

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:

http://plugins.jquery.com/project/color

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