Last active
May 7, 2016 06:03
-
-
Save itswindtw/46a1b05988ba786f6bce33d635e9745d to your computer and use it in GitHub Desktop.
weird behavior in Chrome 50 (Windows only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<script> | |
var test = function (str) { | |
with(Math) { // whatever | |
var scalar = parseFloat(str); | |
var unit = str.replace(/-?\d+(\.\d*)?/g, ""); | |
var unitsToPt = {"cm": 28.34646, "pt": 1.0}; | |
// unitsToPt["cm"] = 28.34646; | |
console.log(unitsToPt); | |
if (scalar == 0 && unitsToPt[unit]) | |
return 0; | |
else if (!unitsToPt[unit]) | |
return str; | |
else | |
return (scalar * unitsToPt[unit]); | |
} | |
} | |
for (var i = 0; i < 1000; i++) { | |
test(27 + i + "cm"); | |
test(0.85 + i + "cm"); | |
test(5.0 + i + "cm"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment