Look at WebKit version instead of checking Safari
Reviewers: emily Reviewed By: emily Differential Revision: http://phabricator.khanacademy.org/D3317
This commit is contained in:
parent
aa4e05a7cf
commit
6883017bc4
5
katex.js
5
katex.js
|
@ -86,8 +86,9 @@ var buildGroup = function(style, color, group, prev) {
|
|||
} else if (group.type === "close") {
|
||||
return makeSpan("mclose" + color, [textit(group.value)]);
|
||||
} else if (group.type === "frac") {
|
||||
if (utils.isSafari) {
|
||||
throw new ParseError("KaTeX fractions don't work in Safari");
|
||||
if (utils.isBuggyWebKit) {
|
||||
throw new ParseError(
|
||||
"KaTeX fractions don't work in WebKit <= 537.1");
|
||||
}
|
||||
|
||||
var fstyle = style;
|
||||
|
|
32
utils.js
32
utils.js
|
@ -13,17 +13,37 @@ function slowContains(list, elem) {
|
|||
|
||||
var contains = Array.prototype.indexOf ? fastContains : slowContains;
|
||||
|
||||
function isSafari() {
|
||||
function isBuggyWebKit() {
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
// Steal these regexes from jQuery migrate for browser detection
|
||||
var webkit = /(webkit)[ \/]([\w.]+)/.exec(userAgent);
|
||||
var chrome = /(chrome)[ \/]([\w.]+)/.exec(userAgent);
|
||||
var webkit = (/applewebkit\/(\d+)\.(\d+)/).exec(userAgent);
|
||||
if (!webkit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return webkit && !chrome;
|
||||
var major = +webkit[1];
|
||||
var minor = +webkit[2];
|
||||
|
||||
// 537.1 is last buggy, according to Chrome's bisect-builds.py which says:
|
||||
//
|
||||
// You are probably looking for a change made after 137695 (known bad), but
|
||||
// no later than 137702 (first known good).
|
||||
// CHANGELOG URL:
|
||||
// http://build.chromium.org/f/chromium/perf/dashboard/ui/changelog.html?url=/trunk/src&range=137695%3A137702
|
||||
//
|
||||
// Downloading these two builds:
|
||||
// http://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/137695/chrome-mac.zip
|
||||
// http://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/137702/chrome-mac.zip
|
||||
// verifies this claim. The respective WebKit versions (r117232 and
|
||||
// r117456) both are called 537.1 so let's throw out 537.1 as well as
|
||||
// everything older.
|
||||
//
|
||||
// The responsible WebKit changeset appears to be this one:
|
||||
// http://trac.webkit.org/changeset/117339/
|
||||
return major < 537 || (major == 537 && minor <= 1);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
contains: contains,
|
||||
isSafari: isSafari()
|
||||
isBuggyWebKit: isBuggyWebKit()
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user