The tagName and nodeName properties only return the value in upper case for HTML, not XHTML. The MDN web docs say:

In XHTML (or any other XML format), the original case will be maintained, so "span" would be output in case the original tag name was created lowercase. In HTML, "SPAN" would be output instead regardless of the case used while creating the original document.

Final thoughts

This caused problems for me today in a couple of commonly used JS libraries, specifically FancySelect and Bootstrap: tooltip (both of which assume these values are returned in upper case), and illustrates the still dangerous terrain that is web development. Sure, things are better than they were before (remember the issues with IE < 11?), but we're most definitely not quite there yet.

Previous on JavaScript
Mastodon Mastodon