aboutsummaryrefslogtreecommitdiff
path: root/exampleData/ruleSets/accessibility/colorBrightness.js
diff options
context:
space:
mode:
Diffstat (limited to 'exampleData/ruleSets/accessibility/colorBrightness.js')
-rw-r--r--exampleData/ruleSets/accessibility/colorBrightness.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/exampleData/ruleSets/accessibility/colorBrightness.js b/exampleData/ruleSets/accessibility/colorBrightness.js
index 737e0d6..96ed1af 100644
--- a/exampleData/ruleSets/accessibility/colorBrightness.js
+++ b/exampleData/ruleSets/accessibility/colorBrightness.js
@@ -26,14 +26,24 @@ exports.rule = function() {
};
var that = this;
- fiveui.query('*').each(function (i) {
- var fg = fiveui.color.colorToRGB($(this).attr('color'));
- var bg = fiveui.color.colorToRGB($(this).attr('background'));
- if (fg && bg) {
- var diff = brightDiff(fg, bg);
- if (diff < MIN_DIFF) {
- that.report('Element has poor brightness difference: ' + diff, e);
+
+ fiveui.query('*')
+ .filter(function () { // filter for lowest level elts having non-empty text
+ var $this = $(this);
+ return $this.children().length == 0 && $.trim($this.text()).length > 0;
+ })
+ .each(function (i) {
+ var fg = fiveui.color.colorToRGB($(this).css('color'));
+ var bg = fiveui.color.colorToRGB($(this).css('background-color'));
+ if (fg && bg) {
+ var diff = brightDiff(fg, bg);
+ if (diff < MIN_DIFF) {
+ that.report('Element has poor brightness difference: ' +
+ 'fg = ' + JSON.stringify(fg) +
+ ', fgb = ' + bright(fg) +
+ ', bg = ' + JSON.stringify(bg) +
+ ', bgb = ' + bright(bg), this);
+ }
}
- }
- });
+ });
};