Describe the bug
XMLDocument.createElement() uppercases element names even though XML element names are case-sensitive.
When parsing a document as text/xml, calling createElement('myNode') results in an element whose nodeName and tagName are "MYNODE" instead of "myNode".
StackBliz
To Reproduce
-
Create an XML document:
const doc = new DOMParser().parseFromString('<root/>', 'text/xml');
-
Create an element:
const element = doc.createElement('myNode');
-
Inspect the element:
console.log(element.nodeName);
console.log(element.tagName);
Current output:
Expected behavior
The element name should be preserved exactly as provided when using an XMLDocument.
Expected output:
This is the behavior defined for XML documents, where element names are case-sensitive.
Device and details:
- OS: Ubuntu 20.04.0 LTS
- Node version: 22.22.3
- Package version: 20.11.1
Additional context
This appears to be HTML createElement() behavior being applied to XMLDocument. Parsing existing XML preserves the original case correctly, but creating new elements programmatically does not.
Describe the bug
XMLDocument.createElement()uppercases element names even though XML element names are case-sensitive.When parsing a document as
text/xml, callingcreateElement('myNode')results in an element whosenodeNameandtagNameare"MYNODE"instead of"myNode".StackBliz
To Reproduce
Create an XML document:
Create an element:
Inspect the element:
Current output:
Expected behavior
The element name should be preserved exactly as provided when using an
XMLDocument.Expected output:
This is the behavior defined for XML documents, where element names are case-sensitive.
Device and details:
Additional context
This appears to be HTML
createElement()behavior being applied toXMLDocument. Parsing existing XML preserves the original case correctly, but creating new elements programmatically does not.