mathml.js 850 B

1234567891011121314151617181920212223
  1. // MathML
  2. // http://www.w3.org/Math/
  3. // By Addy Osmani
  4. // Based on work by Davide (@dpvc) and David (@davidcarlisle)
  5. // in https://github.com/mathjax/MathJax/issues/182
  6. Modernizr.addTest('mathml', function(){
  7. var hasMathML = false;
  8. if ( document.createElementNS ) {
  9. var ns = "http://www.w3.org/1998/Math/MathML",
  10. div = document.createElement("div");
  11. div.style.position = "absolute";
  12. var mfrac = div.appendChild(document.createElementNS(ns,"math"))
  13. .appendChild(document.createElementNS(ns,"mfrac"));
  14. mfrac.appendChild(document.createElementNS(ns,"mi"))
  15. .appendChild(document.createTextNode("xx"));
  16. mfrac.appendChild(document.createElementNS(ns,"mi"))
  17. .appendChild(document.createTextNode("yy"));
  18. document.body.appendChild(div);
  19. hasMathML = div.offsetHeight > div.offsetWidth;
  20. }
  21. return hasMathML;
  22. });