Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

axs.utils.isLargeFont returns incorrect values with non-integer fonts #345

Open
timmhayes opened this issue Apr 28, 2017 · 0 comments
Open

Comments

@timmhayes
Copy link

The axs.utils.isLargeFont() function fails on font sizes with float values.

I saw this first when testing a value of 10pt, which gets a computed value of 13.3333px in Chrome. The current function evaluates this incorrectly as a large font with a value of "3333px". Or conversely, a font value of 30.1px evaluates incorrectly as a small font with a value of "1px"

See a working example here: http://jsbin.com/cehiben/edit?html,output

A small chunk of testable code extracted from isLargeFont() shows the issue:

 var fontSize = "13.3333px"
 var matches = fontSize.match(/(\d+)px/);
 if (matches) {
   var fontSizePx = parseInt(matches[1], 10); // parses as 3333, not 13
   console.log(fontSizePx)
 }

I'll submit a pull request with a suggested fix.

This is also causing a failure in Khan Academy's tota11y toolkit.

timmhayes added a commit to timmhayes/accessibility-developer-tools that referenced this issue Apr 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant