From 2d1115f7276415eff87d54e9b43b206bf4c43f98 Mon Sep 17 00:00:00 2001 From: Benjamin Jones Date: Wed, 19 Dec 2012 17:21:40 -0800 Subject: changed interface to colorToHex to be more robust --- contexts/data/fiveui/injected/prelude.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'contexts/data/fiveui/injected/prelude.js') diff --git a/contexts/data/fiveui/injected/prelude.js b/contexts/data/fiveui/injected/prelude.js index 825f769..abe249e 100644 --- a/contexts/data/fiveui/injected/prelude.js +++ b/contexts/data/fiveui/injected/prelude.js @@ -256,6 +256,9 @@ fiveui.color.colorCheck = function (selector, colorSet) { * Covert rgb colors to hex and abreviated hex colors to their full 3 byte * form. * + * In case there are parse errors during the conversion, i.e. color values + * that are not understood, the input is returned unchanged. + * * @param {!String} color The color string to convert. This should be either of the form rgb(...) or #... * @returns {!String} The color string in #XXXXXX form * @throws {ParseError} if the rgb color string cannot be parsed @@ -279,10 +282,8 @@ fiveui.color.colorToHex = function(color) { var digits = /rgba?\((\d+), (\d+), (\d+)/.exec(color); if (!digits) { - throw { - 'name': 'ParseError', - 'message': 'Could not parse rgb color: ' + color - }; + return color; // in case there is a parse error, we just + // return the input unchanged } var red = parseInt(digits[1]); -- cgit v1.2.3