www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 905fb7fb7130fb3ae9ac7b542601e1df158c1561
parent 79a50b3abebee9613b227e96717d2842f133cd3c
Author: Emily Eisenberg <emily@khanacademy.org>
Date:   Thu, 25 Jul 2013 18:59:20 -0700

Don't run in Safari

Summary: Safari has weird bugs associated with inline-table and
vertical-align, so we just won't render in Safari.

Auditors: alpert

Diffstat:
Mkatex.js | 4++++
Mutils.js | 13++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/katex.js b/katex.js @@ -244,6 +244,10 @@ var clearNode = function(node) { }; var process = function(toParse, baseNode) { + if (utils.isSafari) { + throw new ParseError("KaTeX doesn't work on Safari"); + } + clearNode(baseNode); var tree = parseTree(toParse); diff --git a/utils.js b/utils.js @@ -13,6 +13,17 @@ function slowContains(list, elem) { var contains = Array.prototype.indexOf ? fastContains : slowContains; +function isSafari() { + 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); + + return webkit && !chrome; +} + module.exports = { - contains: contains + contains: contains, + isSafari: isSafari() };