Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added out-of-bounds handling for hslToRgb function with unit tests #193

Merged
merged 1 commit into from
Dec 19, 2013

Conversation

MWers
Copy link
Contributor

@MWers MWers commented Dec 17, 2013

I've added out-of-bounds handling for the hslToRgb function. It normalizes the hue orientation between 0 and 360 degrees and ensures that saturation and lightness are between 0 and 100. I based tests of this functionality on the Webkit CSS tests here:

http://trac.webkit.org/export/98524/trunk/LayoutTests/fast/css/hsl-color.html

@GoalSmashers
Copy link
Contributor

Thanks Matt! Will review it tomorrow (Wed).

On 17 Dec 2013, at 06:05, Matt Walker notifications@github.com wrote:

I've added out-of-bounds handling for the hslToRgb function. It normalizes the hue orientation between 0 and 360 degrees and ensures that saturation and lightness are between 0 and 100. I based tests of this functionality on the Webkit CSS tests here:

http://trac.webkit.org/export/98524/trunk/LayoutTests/fast/css/hsl-color.html

You can merge this Pull Request by running

git pull https://github.com/MWers/clean-css hsl-range
Or view, comment on, or merge it at:

#193

Commit Summary

Added out-of-bounds handling for hslToRgb function and unit tests
File Changes

M lib/colors/hsl-to-hex.js (19)
M test/unit-test.js (30)
Patch Links:

https://github.com/GoalSmashers/clean-css/pull/193.patch
https://github.com/GoalSmashers/clean-css/pull/193.diff

@@ -4,8 +4,25 @@ module.exports = function HSLToHex(data) {
var hslToRgb = function(h, s, l) {
var r, g, b;

// normalize orientation b/w 0 and 360 degrees
h = h % 360;
if (h < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MWers We don't use curly braces with a single statement. Please remove them to keep our style consistent.

@GoalSmashers
Copy link
Contributor

Beside that one comment everything is fine. 👍

@MWers
Copy link
Contributor Author

MWers commented Dec 18, 2013

No problem, 'tis fixed!

@@ -4,8 +4,23 @@ module.exports = function HSLToHex(data) {
var hslToRgb = function(h, s, l) {
var r, g, b;

// normalize hue orientation b/w 0 and 360 degrees
h = h % 360;
if (h < 0) h += 360;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, wasn't specific enough - we prefer the following style:

if (h < 0)
  h += 360;

Two more things:

  1. There are other cases below where braces should be gone.
  2. Please rebase all commits into one once you are done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a missing semicolon - make sure to run npm run check before squashing too.

@MWers
Copy link
Contributor Author

MWers commented Dec 19, 2013

Fixed and (hopefully properly) rebased! ;)

@GoalSmashers
Copy link
Contributor

@MWers Looks great - merging right away!

GoalSmashers pushed a commit that referenced this pull request Dec 19, 2013
Adds out-of-bounds handling for HSL colors.
@GoalSmashers GoalSmashers merged commit f2ac395 into clean-css:master Dec 19, 2013
@GoalSmashers
Copy link
Contributor

@MWers 2.0.4 is out with your fix!

@MWers
Copy link
Contributor Author

MWers commented Dec 19, 2013

Great, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants