Skip to content

Commit e1c4508

Browse files
authored
Update examples.js
1 parent 78f3362 commit e1c4508

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/examples.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var parseColor = function(c) {
5252
};
5353

5454
var getLevel = function(c, module) {
55-
var a = module.abs(c);
55+
var a = Math.abs(c);
5656
for (let i = 0; i < module.arraySize; i++) {
5757
if (a < module.levels[i + 1]) {
5858
return i;
@@ -84,7 +84,8 @@ var addExample = function(fg, bg) {
8484
display.style.fontWeight = font_weight;
8585
display.style.padding = PADDING[wcag_level];
8686

87-
clone.querySelector('.wcag output').textContent = wcag_contrast.toFixed(1);
87+
// trunc is due to AGWG disregarding standard maths
88+
clone.querySelector('.wcag output').textContent = Math.trunc(wcag_contrast * 10) / 10;
8889
clone.querySelector('.wcag .badge').textContent = LEVEL_LABELS[wcag_level];
8990
clone.querySelector('.wcag .badge').classList.add(`badge-${LEVEL_LABELS[wcag_level]}`);
9091

0 commit comments

Comments
 (0)