Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathML pre-processing fails in IE9 #6

Closed
shogun70 opened this issue Oct 15, 2010 · 7 comments
Closed

MathML pre-processing fails in IE9 #6

shogun70 opened this issue Oct 15, 2010 · 7 comments
Labels

Comments

@shogun70
Copy link
Contributor

Using IE9 platform preview 5:

  1. Visit http://s3.amazonaws.com/dist-meekostuff-net/MathJax/default/test/sample-mml.html
  2. Force the browser into IE9 standards mode
  3. The browser notifies an error in mml2jax
  4. Math content is not rendered:
  • inline math doesn't seem to be detected
  • display mode math is detected, but is processed incorrectly.

The incorrect processing may be due to IE9 capability to parse MathML correctly.

@dpvc
Copy link
Member

dpvc commented Oct 22, 2010

If the error is about parentNode being null, I have a fix in my fork of MathJax. (I don't have IE9, as I don't have Windows 7, so can't check what the message is myself.) If that's not it, I'll have to look further.

@shogun70
Copy link
Contributor Author

That's not it. The problem goes away if I turn off msieMathTagBug for IE9, but that reveals another problem similar to the TeX pre-processing one of spurious content. Turning off msieScriptBug fixes that. So currently I'm using the modified code:

MathJax.Hub.Browser.Select({
  MSIE: function (browser) {
    if (MathJax.Hub.Browser.versionAtLeast(9)) return; // 
    MathJax.Hub.Insert(MathJax.Extension.mml2jax,{
      msieScriptBug: true,
      msieMathTagBug: true
    })
  }
});

at the bottom of mml2jax.js.

However, that breaks MathML when IE9 is forced into IE8 or IE7 standards mode.
I'll get to the bottom of it soon.

@shogun70
Copy link
Contributor Author

When IE9 is forced to emulate IE8 or IE7 the userAgent still indicates MSIE 9.0.
If I replace the version check above with document.documentMode >= 9 then everything is fine.

TODO:
Should we develop some feature detection for corrupted mathml parsing?
Or continue to rely on browser detection? If browser detection then should we add a documentMode property or function to MathJax.Hub.Browser?

@dpvc
Copy link
Member

dpvc commented Oct 28, 2010

I haven't tried this, but as I recall, the script bug is that IE < 9 requires you to use script.text to change the value of a script (where others do this by adding a text node). You can probably use a detection for that like

try {MathJax.HTML.Element("script",{},["testing"])} catch (err) {
   MathJax.Extension.mml2jax.msieScriptBug = true;
}

since IE < 9 throws an error trying to add a text node to a script.

As for the math tag bug, that could be detected by

MathJax.Extension.mml2jax.msieMathBug = 
  (MathJax.HTML.Element("span",
    {innerHTML:"<math><mi>x</mi></math>"}).childNodes.length !== 1);

which tests whether the nesting of the math node is not properly handled. (There is another IE bug that will cause it to drop the leading and in this case, but you will still get the text node for x and two nodes for and from this, so it will not be one child node).

I would still do these within a browser test for IE, as I would not want to accidentally set these for other browsers. In particular, Opera had some funny business about script innerHTML as I recall, but I don't remember exactly what, or what versions.

Davide

@shogun70
Copy link
Contributor Author

The msieScriptBug seems potentially a little more complex than that. Here's the code:

if (this.msieScriptBug) {
  var html = math.outerHTML;
  html = html.replace(/<\?import .*?>/i,"").replace(/<\?xml:namespace .*?\/>/i,"");
  script.text = html.replace(/&nbsp;/g,"&#xA0;");
  parent.removeChild(math);
} else {
  var span = MathJax.HTML.Element("span"); span.appendChild(math);
  MathJax.HTML.addText(script,span.innerHTML);
}

Is that for dealing with MathPlayer enabled pages?
For the time being I don't think we should work around the the msieScriptBug issue - it looks like it's hitting a bug in IE9 beta which hopefully gets resolved soon.

@dpvc
Copy link
Member

dpvc commented Oct 28, 2010

There are two other items going on in the ScriptBug area: IE prepends extra tags for import and xml:namespace for MathPlayer, as you suggest. There is also an issue with it adding extra &nbsp; that I no longer completely recall. These may not be needed with IE9; would have to check.

It would probably be OK to put the replacements into the common code and just have the script bug handle the replacement of the script text, as in

var span = MathJax.HTML.Element("span"); span.appendChild(math);
var html = span.innerHTML.replace(/&nbsp;/g,"&#xA0;");
html = html.replace(/<\?import .*?>/i,"").replace(/<\?xml:namespace .*?\/>/i,"");
if (this.msieScriptBug) {script.text = html}
  else {MathJax.HTML.addText(script,span.innerHTML)}

That would at least isolate the error processing to the error flag better. Perhaps there should be another one for stripping off the import/namespace stuff?

Davide

@dpvc
Copy link
Member

dpvc commented Nov 2, 2010

I have committed the change, so am closing this issue. (There is still some useful information here, however, with code samples that we didn't include in the update.)

physikerwelt added a commit to physikerwelt/MathJax that referenced this issue Nov 5, 2015
Use master branch for main development
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants