diff --git a/lib/checks/color/color-contrast.js b/lib/checks/color/color-contrast.js index 101888379c..4790056802 100644 --- a/lib/checks/color/color-contrast.js +++ b/lib/checks/color/color-contrast.js @@ -28,9 +28,8 @@ const fgColor = color.getForegroundColor(node, noScroll, bgColor); const nodeStyle = window.getComputedStyle(node); const fontSize = parseFloat(nodeStyle.getPropertyValue('font-size')); -const fontWeight = nodeStyle.getPropertyValue('font-weight'); -const bold = - ['bold', 'bolder', '600', '700', '800', '900'].indexOf(fontWeight) !== -1; +const fontWeight = parseFloat(nodeStyle.getPropertyValue('font-weight')); +const bold = !isNaN(fontWeight) && fontWeight >= 700; const cr = color.hasValidContrastRatio(bgColor, fgColor, fontSize, bold); diff --git a/test/checks/color/color-contrast.js b/test/checks/color/color-contrast.js index 4804335f64..d02ae80aa9 100644 --- a/test/checks/color/color-contrast.js +++ b/test/checks/color/color-contrast.js @@ -44,14 +44,24 @@ describe('color-contrast', function() { it('should return true when there is sufficient contrast because of font weight', function() { var params = checkSetup( - '