Skip to content

Commit 78f3362

Browse files
authored
Update wcag2.js
1 parent a1be4e4 commit 78f3362

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

wcag2.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ export var contrast = function(fg, bg) {
1414
// `c >= 1 ? c : 1 / c` gives you the actual value.
1515
// See also `getAbsRange()`.
1616

17+
// replaced with standard WCAG2 due to rounding errors with xi's version
18+
1719
var yfg = sRGBtoY(fg);
1820
var ybg = sRGBtoY(bg);
19-
return (ybg + 0.05) / (yfg + 0.05);
21+
22+
return yfg>ybg? (yfg + 0.05) / (ybg + 0.05):(ybg + 0.05) / (yfg + 0.05);
2023
};
2124

2225
export var abs = function(c) {
23-
return c < 1 ? 1 / c : c;
26+
return c;
2427
};
2528

2629
export var getAbsRange = function(range) {

0 commit comments

Comments
 (0)