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

Closed
opened this issue Oct 2, 2012 · 4 comments

Projects
None yet
2 participants
Contributor

### fred-wang commented Oct 2, 2012

 Unit test: API/Hub/messagehook-1.html
Contributor Author

### fred-wang commented Jan 31, 2013

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

### dpvc 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

 Skip _moz-math-* attributes in Firefox. Resolves issue mathjax#328 fo… 
…r now.
 c5e1e43 
Member

### dpvc 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 $a$  where the open and close attributes are not valid for XML (they need to be open="<" and close=">"). 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 , for example), then the HTML innerHTML would work as is (though we lose the XML-based error checking that way).

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

 Merge branch 'issue328' into develop. Issue mathjax#328. 
 243141d 

Member

### dpvc commented Feb 15, 2014

 => Merged.