www

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

commit ea5ee95dbec689953c35fa552e1170061a8a945d
parent b7e55607cc14fdb50d82a556738582350cc0f996
Author: Emily Eisenberg <emily@khanacademy.org>
Date:   Wed, 17 Sep 2014 15:13:56 -0700

Warn when the website is in quirks mode

Summary:
KaTeX doesn't work correctly in quirks mode. Warn in the console and disable
rendering if that happens.

Test Plan:
 - Make sure the test still loads and renders math
 - Make sure a warning is thrown when the doctype is removed, and no more math
   is rendered
 - Make sure the tests pass both on the web and with `make test`

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13192

Diffstat:
Mkatex.js | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/katex.js b/katex.js @@ -25,6 +25,20 @@ var render = function(toParse, baseNode) { baseNode.appendChild(node); }; +// KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn( + "Warning: KaTeX doesn't work in quirks mode. Make sure your " + + "website has a suitable doctype."); + + render = function() { + throw new ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} + /** * Parse and build an expression, and return the markup for that. */