diff options
-rw-r--r-- | contexts/data/fiveui/injected/prelude.js | 9 | ||||
-rw-r--r-- | exampleData/ruleSets/colorRules.json | 2 | ||||
-rw-r--r-- | exampleData/ruleSets/imageRules.json | 12 |
3 files changed, 15 insertions, 8 deletions
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]); diff --git a/exampleData/ruleSets/colorRules.json b/exampleData/ruleSets/colorRules.json index 1cea5a0..1aebf19 100644 --- a/exampleData/ruleSets/colorRules.json +++ b/exampleData/ruleSets/colorRules.json @@ -33,7 +33,7 @@ .cssIsNot("background-color", allow, fiveui.color.colorToHex) .each(function (i, elt) { var color = fiveui.color.colorToHex($(elt).css("background-color")); - report("non-standard background color: " + color, elt); + report("non-standard background color: " + color, $(elt)); }); } }, diff --git a/exampleData/ruleSets/imageRules.json b/exampleData/ruleSets/imageRules.json index 05814f9..40d9081 100644 --- a/exampleData/ruleSets/imageRules.json +++ b/exampleData/ruleSets/imageRules.json @@ -17,12 +17,12 @@ , 'rule': function() { var elt = $5("div[id=header]"); // get the div with id=header - var b = elt.css("background"); // get its background CSS property + var b = $5(elt).css("background"); // get its background CSS property var l = $5("a[href]", elt).prop("href"); // get the <a href=...> string inside the div if (/banner\.gif/.test(b)) { report("banner.gif missing", elt); } - if (l.length == 0) { // this list will be empty if there is no link + if (l === null || l.length == 0) { report("banner.gif link is missing", elt); } } @@ -57,7 +57,13 @@ , 'severity': 1 , 'rule': function() { - var norm = function (s) { return /^\w+\s+\w+/.exec(s)[0]; } // select out first two words of the input + // select out first two words of the input + var norm = function (s) { + if (/^\w+\s+\w+/.exec(s)) + return /^\w+\s+\w+/.exec(s)[0]; + else + return "null null"; + }; var imgs = $5("img").not("div.filmstrip *"); // select images not in the filmstrip imgs.cssIsNot("border", "1px solid", norm) .each(function (i, elt) { |