{"size": 1837, "ext": "js", "max_stars_repo_path": "feature-detects/mathml.js", "max_stars_repo_name": "doctyper/Modernizr", "max_stars_repo_stars_event_min_datetime": "2021-08-19T07:48:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-19T07:48:59.000Z", "max_issues_repo_path": "feature-detects/mathml.js", "max_issues_repo_name": "SlexAxton/Modernizr", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "feature-detects/mathml.js", "max_forks_repo_name": "SlexAxton/Modernizr", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.1587301587, "max_line_length": 97, "alphanum_fraction": 0.6020685901}
/*!
{
  "name": "MathML",
  "property": "mathml",
  "caniuse": "mathml",
  "authors": ["Addy Osmani", "Davide P. Cervone", "David Carlisle"],
  "notes": [{
    "name": "W3C spec",
    "href": "http://www.w3.org/Math/"
  }],
  "polyfills": ["mathjax"]
}
!*/
/* DOC

Detects support for MathML, for mathematic equations in web pages.

*/
define(['Modernizr', 'createElement', 'addTest'], function( Modernizr, createElement, addTest ) {
  // Based on work by Davide (@dpvc) and David (@davidcarlisle)
  // in https://github.com/mathjax/MathJax/issues/182

  Modernizr.addAsyncTest('mathml', function() {
    var waitTime = 300;
    setTimeout(runMathMLTest, waitTime);
    // Hack to make sure that the body exists
    // TODO:: find a more reasonable method of
    // doing this.
    function runMathMLTest() {
      if (!document.body && !document.getElementsByTagName('body')[0]) {
        setTimeout(runMathMLTest, waitTime);
        return;
      }
      addTest(function () {
        var hasMathML = false;
        if ( document.createElementNS ) {
          var ns = "http://www.w3.org/1998/Math/MathML";
          var div = createElement("div");

          div.style.position = "absolute";

          var mfrac = div.appendChild(document.createElementNS(ns,"math"))
                         .appendChild(document.createElementNS(ns,"mfrac"));

          mfrac.appendChild(document.createElementNS(ns,"mi"))
               .appendChild(document.createTextNode("xx"));

          mfrac.appendChild(document.createElementNS(ns,"mi"))
               .appendChild(document.createTextNode("yy"));

          document.body.appendChild(div);

          hasMathML = div.offsetHeight > div.offsetWidth;

          // Clean up the element
          document.body.removeChild(div);
        }
        return hasMathML;
      });
    }
  });
});
