MathJax.Hub.Queue fails when called from GWT function
Created by: kevinushey
I'm running into trouble using MathJax within a GWT project. I have a GWT function using the native JSNI interface e.g.
private static final native void mathjaxTypeset(String text, Element el) /*-{
var MathJax = $wnd.MathJax;
var f = function(x) { alert(x); };
MathJax.Hub.Queue([f, 15]);
}-*/;
Unfortunately, this fails for the reasons outlined by https://github.com/mathjax/MathJax/issues/508 -- we get a MathJax error of the form
<...> Can't make callback from given data
This ultimately stems from MathJax's use of args instanceof Array -- within the context of GWT, this check fails.
You'll notice that instanceof Array returns false, despite other checks reporting that this is indeed an array. Could this condition be relaxed to use a helper function e.g.
function isArray(object) {
return Object.prototype.toString.call(object) === "[object Array]";
}
Or even Array.isArray() would suffice here.
Thanks! Kevin
