Skip to content

Commit

Permalink
🐛 Fix css color function raising exception when invalid
Browse files Browse the repository at this point in the history
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
  • Loading branch information
abe33 committed Jul 27, 2014
1 parent bb0570b commit a883cca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/color-operations.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit a883cca

Please sign in to comment.