Commit 48a19d0a by Aaron Leung

Adding error checking for hue, saturation, and lightness.

parent c87719a9
......@@ -255,6 +255,7 @@ namespace Sass {
extern Signature hue_sig = "hue($color)";
Node hue(const Node parameter_names, Environment& bindings, Node_Factory& new_Node) {
Node rgb_color(bindings[parameter_names[0].token()]);
if (rgb_color.type() != Node::numeric_color) throw_eval_error("argument to 'hue' must be a color", rgb_color.path(), rgb_color.line());
Node hsl_color(rgb_to_hsl(rgb_color[0].numeric_value(),
rgb_color[1].numeric_value(),
rgb_color[2].numeric_value(),
......@@ -265,6 +266,7 @@ namespace Sass {
extern Signature saturation_sig = "saturation($color)";
Node saturation(const Node parameter_names, Environment& bindings, Node_Factory& new_Node) {
Node rgb_color(bindings[parameter_names[0].token()]);
if (rgb_color.type() != Node::numeric_color) throw_eval_error("argument to 'saturation' must be a color", rgb_color.path(), rgb_color.line());
Node hsl_color(rgb_to_hsl(rgb_color[0].numeric_value(),
rgb_color[1].numeric_value(),
rgb_color[2].numeric_value(),
......@@ -275,6 +277,7 @@ namespace Sass {
extern Signature lightness_sig = "lightness($color)";
Node lightness(const Node parameter_names, Environment& bindings, Node_Factory& new_Node) {
Node rgb_color(bindings[parameter_names[0].token()]);
if (rgb_color.type() != Node::numeric_color) throw_eval_error("argument to 'lightness' must be a color", rgb_color.path(), rgb_color.line());
Node hsl_color(rgb_to_hsl(rgb_color[0].numeric_value(),
rgb_color[1].numeric_value(),
rgb_color[2].numeric_value(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment