diegoles / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

color.js and alpha.js do not support percentages for rgb and rgba #452

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
According to the spec (http://www.w3.org/TR/css3-color/#rgba-color) rgb() and 
rgba() can be specified as either integers or as percentages, but the current 
library does not support that.

What steps will reproduce the problem?
1. goog.color.isValidColor('rgb(100%,0%,0%)')
2. goog.color.parse('rgb(100%,0%,0%)')
3. goog.color.alpha.parse('rgba(100%,0%,0%,100%)')

What is the expected output? What do you see instead?
1. Expect True but receive False.
2. Expect Object but receive error: "rgb(100%,0%,0%) is not a valid color 
string"
3. Expect Object but receive error: "rgb(100%,0%,0%,100%) is not a valid color 
string"

What version of the product are you using? On what operating system?
Firefox 11.0 on OS X 10.7.3

Please provide any additional information below.
I need this for a contribution to Selenium regarding issue 
https://code.google.com/p/selenium/issues/detail?id=1885. I can attempt to 
provide a patch for this to the closure-library if you are interested in one.

Original issue reported on code.google.com by bob.silv...@gmail.com on 20 Apr 2012 at 5:03

GoogleCodeExporter commented 8 years ago
Note, there was an error in the values I used above for the rgba string. 
rgba(100%,0%,0%,100%) is not valid. That should be rgba(100%,0%,0%,1).

As I needed this functionality for the issue I'm working on for the Selenium 
project, I went ahead and added it and am attaching a patch for it. Please let 
me know if the patch is approved, or if changes are required in the way I coded 
it.

Original comment by bob.silv...@gmail.com on 21 Apr 2012 at 1:58

Attachments:

GoogleCodeExporter commented 8 years ago
Here's a newer patch that adds an isValidAlphaColor() method to 
goog.color.alpha, in addition to adding the percentage support to both color 
and alpha.

Original comment by bob.silv...@gmail.com on 22 Apr 2012 at 3:43

Attachments:

GoogleCodeExporter commented 8 years ago
I just opened a code review ticket for this as well (after having read the wiki 
page about contributing). I apologize for not doing that initially. The ticket 
is http://codereview.appspot.com/6095046/.

Original comment by bob.silv...@gmail.com on 23 Apr 2012 at 4:06

GoogleCodeExporter commented 8 years ago

Original comment by chrishe...@google.com on 11 May 2012 at 8:19