From a883ccadb60a3498d01506ab821ed43e39992fe4 Mon Sep 17 00:00:00 2001 From: abe33 Date: Sun, 27 Jul 2014 15:12:00 +0200 Subject: [PATCH] :bug: Fix css color function raising exception when invalid As the other expressions and operations the css color function handler now set the `isInvalid` property to true if the `convert` method raise an exception. Closes abe33/atom-color-highlight#27 --- src/color-operations.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/color-operations.coffee b/src/color-operations.coffee index 75dbc8c..58334df 100644 --- a/src/color-operations.coffee +++ b/src/color-operations.coffee @@ -232,8 +232,11 @@ Color.addExpression 'input', "invert#{ps}(#{notQuote})#{pe}", (color, expression # color(green tint(50%)) Color.addExpression 'css_color_function', "color#{ps}(#{notQuote})#{pe}", (color, expression) -> - rgba = cssColor.convert(expression) - color.rgba = new Color(rgba).rgba + try + rgba = cssColor.convert(expression) + color.rgba = new Color(rgba).rgba + catch e + color.isInvalid = true parseParam = (param, fileVariables={}, block) -> [block, fileVariables] = [fileVariables, {}] if typeof fileVariables is 'function'