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

Firefox: _moz-* attributes appear in the code generated by SourceElement() #328

Closed
fred-wang opened this issue Oct 2, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@fred-wang
Copy link
Contributor

commented Oct 2, 2012

Unit test:

API/Hub/messagehook-1.html

@fred-wang

This comment has been minimized.

Copy link
Contributor Author

commented Jan 31, 2013

For the record, the Bugzilla entry is:
https://bugzilla.mozilla.org/show_bug.cgi?id=527201

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 13, 2014

The _moz-* attributes are removes by the MathML input jax, but that is done when converting the SourceElement() contents to the internal element jax. So the source in the SourceElement() is what come out of the DOM.

I'm not sure it is worth trying to filter it out earlier, especially since I understand that Firefox should be removing those itself in the future. It could be done with a regular expression replacement by the mml2jax preprocessor, but I'm always a little hesitant to do that. The only real reason to do it is that it shows up in the Original MathML source output.

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 14, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 14, 2014

It turns out that these can be filtered without regular expressions.

Because some browsers return innerHTML values that aren't valid XML (e.g., IE < 9 leaves out the quotes from attribute values), the mml2jax preprocessor includes code to build the HTML string by hand (by traversing the tree and creating the string piece-by-piece). From an HTML page, Firefox doesn't quote attributes that include HTML special characters like <, and so you can get things like

<math><mfenced open="<" close=">"><mi>a</mi></mfenced></math>

where the open and close attributes are not valid for XML (they need to be open="&lt;" and close="&gt;"). So using innerHTML to obtain the original MathML string won't work in Firefox since the result may not parse with the XML parser. So MathJax uses its "by hand" method for Firefox. Since this adds the attributes by hand as well, it is easy to filter out the unwanted attributes while building the string (and we don't run into any regexp gotchas).

This turns out to be the reason for the unexpected slowness of the MathML processing compared to SVG that Fred noted at one point.

It would be possible to clone the MathML tree into an XML document and use innerHTML on that to get the correct attribute quoting, and that would certainly speed things up. Alternatively, if we go to the HTML parser rather than the XML one (to handle HTML nodes in <mtext>, for example), then the HTML innerHTML would work as is (though we lose the XML-based error checking that way).

@dpvc dpvc added Accepted labels Feb 14, 2014

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 15, 2014

@dpvc dpvc added Merged and removed Ready for Review labels Feb 15, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 15, 2014

=> Merged.

@dpvc dpvc closed this Feb 15, 2014

@dpvc dpvc added v2.4 and removed Merged labels Jun 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.