Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /dom/nodes/Element-tagName.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Element.tagName</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
assert_equals(document.createElementNS(HTMLNS, "I").tagName, "I")
assert_equals(document.createElementNS(HTMLNS, "i").tagName, "I")
assert_equals(document.createElementNS(HTMLNS, "x:b").tagName, "X:B")
}, "tagName should upper-case for HTML elements in HTML documents.")
test(function() {
assert_equals(document.createElementNS(SVGNS, "svg").tagName, "svg")
assert_equals(document.createElementNS(SVGNS, "SVG").tagName, "SVG")
assert_equals(document.createElementNS(SVGNS, "s:svg").tagName, "s:svg")
assert_equals(document.createElementNS(SVGNS, "s:SVG").tagName, "s:SVG")
assert_equals(document.createElementNS(SVGNS, "textPath").tagName, "textPath");
}, "tagName should not upper-case for SVG elements in HTML documents.")
test(() => {
assert_equals(el2.tagName, "mixedCase");
}, "tagName should not upper-case for other non-HTML namespaces");
test(function() {
if ("DOMParser" in window) {
var xmlel = new DOMParser()
.documentElement;
assert_equals(xmlel.tagName, "div", "tagName should be lowercase in XML")
var htmlel = document.importNode(xmlel, true)
assert_equals(htmlel.tagName, "DIV", "tagName should be uppercase in HTML")
}
}, "tagName should be updated when changing ownerDocument")
test(function() {
var xmlel = document.implementation
.documentElement;
assert_equals(xmlel.tagName, "div", "tagName should be lowercase in XML")
var htmlel = document.importNode(xmlel, true)
assert_equals(htmlel.tagName, "DIV", "tagName should be uppercase in HTML")
}, "tagName should be updated when changing ownerDocument (createDocument without prefix)")
test(function() {
var xmlel = document.implementation
.documentElement;
assert_equals(xmlel.tagName, "foo:div", "tagName should be lowercase in XML")
var htmlel = document.importNode(xmlel, true)
assert_equals(htmlel.tagName, "FOO:DIV", "tagName should be uppercase in HTML")
}, "tagName should be updated when changing ownerDocument (createDocument with prefix)")
</script>