Skip to content

Commit

Permalink
Addresses issue GoogleChrome#345
Browse files Browse the repository at this point in the history
  • Loading branch information
timmhayes committed Apr 28, 2017
1 parent e12bfeb commit 0907cd2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/js/AccessibilityUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,15 @@ axs.utils.elementIsVisible = function(element) {
axs.utils.isLargeFont = function(style) {
var fontSize = style.fontSize;
var bold = style.fontWeight == 'bold';
var matches = fontSize.match(/(\d+)px/);
var matches = fontSize.match(/(\d+(\.\d+)?)px/);

if (matches) {
var fontSizePx = parseInt(matches[1], 10);
var fontSizePx = parseFloat(matches[1]);
var bodyStyle = window.getComputedStyle(document.body, null);
var bodyFontSize = bodyStyle.fontSize;
matches = bodyFontSize.match(/(\d+)px/);
matches = bodyFontSize.match(/(\d+(\.\d+)?)px/);
if (matches) {
var bodyFontSizePx = parseInt(matches[1], 10);
var bodyFontSizePx = parseFloat(matches[1]);
var boldLarge = bodyFontSizePx * 1.2;
var large = bodyFontSizePx * 1.5;
} else {
Expand All @@ -298,23 +299,23 @@ axs.utils.isLargeFont = function(style) {
}
return (bold && fontSizePx >= boldLarge || fontSizePx >= large);
}
matches = fontSize.match(/(\d+)em/);
matches = fontSize.match(/(\d+(\.\d+)?)em/);
if (matches) {
var fontSizeEm = parseInt(matches[1], 10);
var fontSizeEm = parseFloat(matches[1]);
if (bold && fontSizeEm >= 1.2 || fontSizeEm >= 1.5)
return true;
return false;
}
matches = fontSize.match(/(\d+)%/);
matches = fontSize.match(/(\d+(\.\d+)?)%/);
if (matches) {
var fontSizePercent = parseInt(matches[1], 10);
var fontSizePercent = parseFloat(matches[1]);
if (bold && fontSizePercent >= 120 || fontSizePercent >= 150)
return true;
return false;
}
matches = fontSize.match(/(\d+)pt/);
matches = fontSize.match(/(\d+(\.\d+)?)pt/);
if (matches) {
var fontSizePt = parseInt(matches[1], 10);
var fontSizePt = parseFloat(matches[1]);
if (bold && fontSizePt >= 14 || fontSizePt >= 18)
return true;
return false;
Expand Down

0 comments on commit 0907cd2

Please sign in to comment.