// // References important to this particular implementation: // - http://ejohn.org/blog/nodename-case-sensitivity/ // - http://help.dottoro.com/ljdgsrle.php // - http://www.w3schools.com/html/html_xhtml.asp // - http://www.w3schools.com/tags/tag_doctype.asp // // Other related references if additional parameters are ever needed: // - http://reference.sitepoint.com/javascript/Document/doctype // - http://reference.sitepoint.com/javascript/DocumentType // - http://help.dottoro.com/ljlsvbgj.php // - http://nimbupani.com/the-truth-about-doctypes.html // // Implementation explanation: // - If a document is being rendered in HTML mode, then all `.nodeName` properties // return their values in all uppercase (e.g. `HTML`). // - If a document is being rendered in XML/XHTML mode, then all `.nodeName` properties // return their values in their original case. However, valid XHTML also requires all // element names to be specified as lowercase, so the original case MUST always be // lowercase (e.g. `html`). function isXhtmlDoc( doc ) { var _doc = doc || ( typeof document !== 'undefined' && document ); return _doc && _doc.documentElement && _doc.documentElement.nodeName === 'html'; }